mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56830 Opt into formatting on GitHub and format everything. This is a trial run before turning on formatting for more and eventually all of the codebase. Test Plan: CI Reviewed By: zertosh Differential Revision: D27979080 fbshipit-source-id: a80f0c48691c08ae8ca0af06377b87e6a2351151
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <c10/core/DeviceType.h>
|
|
#include <c10/util/Exception.h>
|
|
|
|
namespace c10 {
|
|
|
|
/**
|
|
* QScheme is an enum that specifies the type of quantization. This has a one
|
|
* to one correspondence with Quantizer
|
|
* Please refer to ATen/quantized/Quantizer.h to see the Quantizers classes.
|
|
* Keep this file in sync with torch/nn/_qscheme.py
|
|
*/
|
|
enum class QScheme : uint8_t {
|
|
PER_TENSOR_AFFINE = 0,
|
|
PER_CHANNEL_AFFINE = 1,
|
|
PER_TENSOR_SYMMETRIC = 2,
|
|
PER_CHANNEL_SYMMETRIC = 3,
|
|
PER_CHANNEL_AFFINE_FLOAT_QPARAMS = 4,
|
|
COMPILE_TIME_NUM_QSCHEMES = 5,
|
|
};
|
|
|
|
constexpr auto kPerTensorAffine = QScheme::PER_TENSOR_AFFINE;
|
|
constexpr auto kPerChannelAffine = QScheme::PER_CHANNEL_AFFINE;
|
|
constexpr auto kPerTensorSymmetric = QScheme::PER_TENSOR_SYMMETRIC;
|
|
constexpr auto kPerChannelSymmetric = QScheme::PER_CHANNEL_SYMMETRIC;
|
|
constexpr auto kPerChannelAffineFloatQParams =
|
|
QScheme::PER_CHANNEL_AFFINE_FLOAT_QPARAMS;
|
|
constexpr int COMPILE_TIME_NUM_QSCHEMES =
|
|
static_cast<int>(QScheme::COMPILE_TIME_NUM_QSCHEMES);
|
|
|
|
inline std::string toString(QScheme qscheme) {
|
|
switch (qscheme) {
|
|
case kPerTensorAffine:
|
|
return "per_tensor_affine";
|
|
case kPerChannelAffine:
|
|
return "per_channel_affine";
|
|
case kPerTensorSymmetric:
|
|
return "per_tensor_symmetric";
|
|
case kPerChannelSymmetric:
|
|
return "per_channel_symmetric";
|
|
case kPerChannelAffineFloatQParams:
|
|
return "per_channel_affine_float_qparams";
|
|
default:
|
|
TORCH_CHECK(false, "Unrecognized qscheme: ", static_cast<int>(qscheme));
|
|
}
|
|
}
|
|
|
|
} // namespace c10
|