Caffe2 - C++ API
A deep learning, cross platform ML framework
tanh_dnnlowp_op.cc
1 #include "caffe2/quantization/server/elementwise_dnnlowp_op.h"
2 #include "caffe2/quantization/server/tanh.h"
3 
4 namespace caffe2 {
5 
6 using namespace dnnlowp;
7 
8 template <typename T>
9 class TanhFunctor {
10  public:
11  explicit TanhFunctor() : tanh_() {}
12 
13  inline void operator()(const int n, const T* x, T* y) {
14  for (int i = 0; i < n; ++i) {
15  y[i] = tanh_.Compute(x[i]);
16  }
17  }
18 
19  TensorQuantizationParams GetOutputQuantizationParams() const {
20  return tanh_.GetOutputQuantizationParams();
21  }
22 
23  private:
24  Tanh<T> tanh_;
25 };
26 
27 REGISTER_CPU_OPERATOR_WITH_ENGINE(
28  Tanh,
29  DNNLOWP,
30  UnaryElementwiseWithArgsDNNLowPOp<std::uint8_t, TanhFunctor<std::uint8_t>>);
31 
32 REGISTER_CPU_OPERATOR_WITH_ENGINE(
33  Int8Tanh,
34  DNNLOWP,
35  UnaryElementwiseWithArgsDNNLowPOp<std::uint8_t, TanhFunctor<std::uint8_t>>);
36 
37 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13
We use the 3-region approach described in "Efficient VLSI Implementation of Neural Networks with Hype...
Definition: tanh.h:21