Download modules/dnn/src/cuda4dnn/primitives/softmax.hpp from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/tgollogly/test/resolve/main/modules/dnn/src/cuda4dnn/primitives/softmax.hpp
- Command line
-
hf download hf://tgollogly/test/modules/dnn/src/cuda4dnn/primitives/softmax.hpp
-
curl -L -o softmax.hpp https://huggingface.co/tgollogly/test/resolve/main/modules/dnn/src/cuda4dnn/primitives/softmax.hpp
1.69 kB
| // This file is part of OpenCV project. | |
| // It is subject to the license terms in the LICENSE file found in the top-level directory | |
| // of this distribution and at http://opencv.org/license.html. | |
| namespace cv { namespace dnn { namespace cuda4dnn { | |
| template <class T> | |
| class SoftmaxOp final : public CUDABackendNode { | |
| public: | |
| using wrapper_type = GetCUDABackendWrapperType<T>; | |
| SoftmaxOp(csl::cudnn::Handle handle, std::size_t axis_, bool log_) | |
| : cudnnHandle(std::move(handle)), channel_axis{ axis_ }, log{ log_ } | |
| { | |
| } | |
| void forward( | |
| const std::vector<cv::Ptr<BackendWrapper>>& inputs, | |
| const std::vector<cv::Ptr<BackendWrapper>>& outputs, | |
| csl::Workspace& workspace) override | |
| { | |
| for (int i = 0; i < inputs.size(); i++) | |
| { | |
| auto input_wrapper = inputs[i].dynamicCast<wrapper_type>(); | |
| auto input = input_wrapper->getView(); | |
| auto output_wrapper = outputs[i].dynamicCast<wrapper_type>(); | |
| auto output = output_wrapper->getSpan(); | |
| csl::tensor_ops::softmax<T>(cudnnHandle, output, input, channel_axis, log); | |
| } | |
| } | |
| private: | |
| csl::cudnn::Handle cudnnHandle; | |
| std::size_t channel_axis; | |
| bool log; | |
| }; | |
| }}} /* namespace cv::dnn::cuda4dnn */ | |