Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/dnn/src/vkcom/include/op_softmax.hpp
16344 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
//
5
// Copyright (C) 2018, Intel Corporation, all rights reserved.
6
// Third party copyrights are property of their respective owners.
7
8
#ifndef OPENCV_DNN_VKCOM_OP_SOFTMAX_HPP
9
#define OPENCV_DNN_VKCOM_OP_SOFTMAX_HPP
10
11
#include "vkcom.hpp"
12
#include "op_base.hpp"
13
14
namespace cv { namespace dnn { namespace vkcom {
15
16
#ifdef HAVE_VULKAN
17
18
struct SoftmaxShaderConfig
19
{
20
int local_size_x;
21
int local_size_y;
22
int local_size_z;
23
int block_height;
24
int block_width;
25
int block_depth;
26
};
27
28
class OpSoftmax: public OpBase
29
{
30
public:
31
OpSoftmax(const int axis, const bool log_softmax = false);
32
~OpSoftmax();
33
void reshapeOutTensor(Tensor& in, Tensor& out);
34
bool forward(Tensor& in, Tensor& out);
35
virtual bool forward(std::vector<Tensor>& ins,
36
std::vector<Tensor>& blobs,
37
std::vector<Tensor>& outs) CV_OVERRIDE;
38
private:
39
bool init(const int axis, const bool log_softmax);
40
bool computeGroupCount();
41
42
int axis_;
43
int channels_;
44
int channel_size_;
45
int outer_size_;
46
bool log_softmax_;
47
SoftmaxShaderConfig config_;
48
Tensor* max_tensor_;
49
Tensor* sum_tensor_;
50
};
51
52
#endif // HAVE_VULKAN
53
54
}}} // namespace cv::dnn::vkcom
55
56
#endif // OPENCV_DNN_VKCOM_OP_SOFTMAX_HPP
57
58