pytorch/caffe2/quantization/server/int8_gen_quant_params.cc
Nikita Shulga a9b0a921d5 Disable avoid-non-const-global-variables lint check (#62008)
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
2021-07-22 18:04:40 -07:00

40 lines
1.4 KiB
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#include "caffe2/quantization/server/int8_gen_quant_params.h"
#include <functional>
namespace caffe2 {
using namespace std;
using namespace dnnlowp;
// Expilictly register TypeMeta
CAFFE_KNOWN_TYPE(unique_ptr<Int8QuantSchemeBlob>);
CAFFE_KNOWN_TYPE(unique_ptr<Int8QuantParamsBlob>);
REGISTER_CPU_OPERATOR(
Int8GenQuantParams,
Int8GenQuantParamsOp<CPUContext, DefaultEngine>);
OPERATOR_SCHEMA(Int8GenQuantParams)
.NumInputs(2)
.NumOutputs(1)
.TensorInferenceFunction([](const OperatorDef& /* def */,
const vector<TensorShape>& in) {
vector<TensorShape> out(1);
out[0].set_data_type(TensorProto_DataType_FLOAT);
out[0].add_dims(1);
return out;
})
.Input(
0,
"X",
"The input data, or last N samples of the output activations.")
.Input(
1,
"quant_scheme",
"Int8QuantSchemeBlob that specifies the quantization kind and preserve_sparsity options when generating the quant params.")
.Output(
0,
"quant_param",
"Int8QuantParamsBlob that contains the scale and zero_point info in TensorQuantizationParams type.")
.SetDoc(
R"DOC(Operator wrapper for generating int8 tensor quantization parameters given the input data and quant scheme)DOC");
} // namespace caffe2