mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: As GoogleTest `TEST` macro is non-compliant with it as well as `DEFINE_DISPATCH` All changes but the ones to `.clang-tidy` are generated using following script: ``` for i in `find . -type f -iname "*.c*" -or -iname "*.h"|xargs grep cppcoreguidelines-avoid-non-const-global-variables|cut -f1 -d:|sort|uniq`; do sed -i "/\/\/ NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)/d" $i; done ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/62008 Reviewed By: driazati, r-barnes Differential Revision: D29838584 Pulled By: malfet fbshipit-source-id: 1b2f8602c945bd4ce50a9bfdd204755556e31d13
47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
#include "caffe2/operators/quantized/int8_softmax_op.h"
|
|
|
|
namespace caffe2 {
|
|
|
|
REGISTER_CPU_OPERATOR(Int8Softmax, int8::Int8SoftmaxOp);
|
|
|
|
OPERATOR_SCHEMA(Int8Softmax)
|
|
.NumInputs(1)
|
|
.NumOutputs(1)
|
|
.Arg("Y_scale", "Output tensor quantization scale")
|
|
.Arg("Y_zero_point", "Output tensor quantization offset")
|
|
.IdenticalTypeAndShape()
|
|
.SetDoc(R"DOC(
|
|
The operator computes the softmax normalized values for each layer in the batch
|
|
of the given input. The input is a 2-D tensor (Tensor<float>) of size
|
|
(batch_size x input_feature_dimensions). The output tensor has the same shape
|
|
and contains the softmax normalized values of the corresponding input.
|
|
|
|
X does not need to explicitly be a 2D vector; rather, it will be
|
|
coerced into one. For an arbitrary n-dimensional tensor
|
|
X \in [a_0, a_1, ..., a_{k-1}, a_k, ..., a_{n-1}] and k is
|
|
the axis provided, then X will be coerced into a 2-dimensional tensor with
|
|
dimensions [a_0 * ... * a_{k-1}, a_k * ... * a_{n-1}]. For the default
|
|
case where axis=1, this means the X tensor will be coerced into a 2D tensor
|
|
of dimensions [a_0, a_1 * ... * a_{n-1}], where a_0 is often the batch size.
|
|
In this situation, we must have a_0 = N and a_1 * ... * a_{n-1} = D.
|
|
Each of these dimensions must be matched correctly, or else the operator
|
|
will throw errors.
|
|
)DOC")
|
|
.Arg(
|
|
"axis",
|
|
"(int) default to 1; describes the axis of the inputs when coerced "
|
|
"to 2D; defaults to one because the 0th axis most likely describes "
|
|
"the batch_size")
|
|
.Input(
|
|
0,
|
|
"input",
|
|
"The input tensor that's coerced into a 2D matrix of size (NxD) "
|
|
"as described above.")
|
|
.Output(
|
|
0,
|
|
"output",
|
|
"The softmax normalized output values with the same "
|
|
"shape as input tensor.");
|
|
|
|
} // namespace caffe2
|