| 42 | } // anonymous namespace |
| 43 | |
| 44 | void SoftmaxForwardImpl::exec( |
| 45 | _megdnn_tensor_in src, _megdnn_tensor_out dst, _megdnn_workspace workspace) { |
| 46 | auto dtype_dest = dst.layout.dtype.enumv(); |
| 47 | megdnn_assert( |
| 48 | check_dtype_float_ieee(dtype_dest), |
| 49 | "Cambricon unsupport SoftmaxForward with dtype:%d", |
| 50 | static_cast<int>(dtype_dest)); |
| 51 | auto cnnl_handler = cnnl_handle(this->handle()); |
| 52 | TensorLayout reshape_layout{ |
| 53 | TensorShape{init_shape(src, param().axis)}, dst.layout.dtype}; |
| 54 | reshape_layout.init_contiguous_stride(); |
| 55 | CnnlTensorDescriptor src_desc, dst_desc; |
| 56 | src_desc.set(reshape_layout); |
| 57 | dst_desc.set(reshape_layout); |
| 58 | |
| 59 | cnnl_check(cnnlSoftmaxForward_v2( |
| 60 | cnnl_handler, cnnlSoftmaxAlgorithm_t::CNNL_SOFTMAX_ACCURATE, |
| 61 | cnnlSoftmaxMode_t::CNNL_SOFTMAX_MODE_MEDIUM_DIMENSION, |
| 62 | cnnlComputationPreference_t::CNNL_COMPUTATION_HIGH_PRECISION, nullptr, |
| 63 | src_desc.desc(), src.raw_ptr(), nullptr, dst_desc.desc(), dst.raw_ptr())); |
| 64 | } |
| 65 | |
| 66 | //================================Softmax Backward============================ |
| 67 |
nothing calls this directly
no test coverage detected