MagmaDNN  1.0
c++NeuralNetworkFramework
softmax.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include "tensor/tensor.h"
12 #include "utilities_internal.h"
13 #include "types.h"
14 
15 #if defined(_HAS_CUDA_)
16 #include "cudnn.h"
17 #endif
18 
19 namespace magmadnn {
20 namespace math {
21 
22 #if defined(_HAS_CUDA_)
23 struct cudnn_softmax_settings_t {
24  cudnnHandle_t handle;
25  cudnnSoftmaxAlgorithm_t alg;
26  cudnnSoftmaxMode_t mode;
27  cudnnTensorDescriptor_t xdesc;
28  cudnnTensorDescriptor_t ydesc;
29 };
30 
31 struct cudnn_softmax_grad_settings_t {
32  cudnnHandle_t handle;
33  cudnnSoftmaxAlgorithm_t alg;
34  cudnnSoftmaxMode_t mode;
35  cudnnTensorDescriptor_t ydesc;
36  cudnnTensorDescriptor_t dydesc;
37  cudnnTensorDescriptor_t dxdesc;
38 };
39 #endif
40 
41 template <typename T>
42 void softmax(Tensor<T> *x, Tensor<T> *out);
43 
44 template <typename T>
45 void softmax_grad(Tensor<T> *softmax, Tensor<T> *grad, Tensor<T> *out);
46 
47 #if defined(_HAS_CUDA_)
48 template <typename T>
49 void softmax_device(Tensor<T> *x, Tensor<T> *out, cudnn_softmax_settings_t settings);
50 
51 template <typename T>
52 void softmax_grad_device(Tensor<T> *y, Tensor<T> *grad, Tensor<T> *out, cudnn_softmax_grad_settings_t settings);
53 #endif
54 
55 }
56 }
Definition: addop.cpp:11