Caffe2 - C++ API
A deep learning, cross platform ML framework
sigmoid.h
1 #pragma once
2 
3 #include "tanh.h"
4 
5 namespace dnnlowp {
6 
12 template <typename T>
13 class Sigmoid {
14  public:
15  Sigmoid(double max_abs_err_ = Tanh<T>::DEFAULT_MAX_ABS_ERR);
16 
17  T Compute(T x) const;
18 
19  TensorQuantizationParams GetInputQuantizationParams() const {
20  return in_qparams_;
21  }
22  TensorQuantizationParams GetOutputQuantizationParams() const {
23  return out_qparams_;
24  }
25 
26  private:
27  const int num_in_bits_ = Tanh<T>::DEFAULT_NUM_IN_BITS;
28  const int num_out_bits_ = Tanh<T>::DEFAULT_NUM_OUT_BITS;
29  Tanh<T> tanh_;
30  TensorQuantizationParams in_qparams_, out_qparams_;
31 }; // class Sigmoid
32 
33 } // namespace dnnlowp
sigmoid(x) = (tanh(x/2) + 1)/2 Quantized sigmoid is computed as tanh under the hood, we just use different input/output quantization parameters.
Definition: sigmoid.h:13
We use the 3-region approach described in "Efficient VLSI Implementation of Neural Networks with Hype...
Definition: tanh.h:21