diff options
author | Jerry Zhang <jerryzh@fb.com> | 2019-04-17 16:10:05 -0700 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-04-17 16:17:40 -0700 |
commit | ad8f34fcca6aadbe0711227e43f87ae47cf417eb (patch) | |
tree | 2708643a6bab2bea35cf632ac6ace61e7bb2c59e /c10 | |
parent | 4371cb5e0193d2eaa8d23673eb153874113eab4e (diff) | |
download | pytorch-ad8f34fcca6aadbe0711227e43f87ae47cf417eb.tar.gz pytorch-ad8f34fcca6aadbe0711227e43f87ae47cf417eb.tar.bz2 pytorch-ad8f34fcca6aadbe0711227e43f87ae47cf417eb.zip |
Add empty_quantized (#18960)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18960
empty_affine_quantized creates an empty affine quantized Tensor from scratch.
We might need this when we implement quantized operators.
Differential Revision: D14810261
fbshipit-source-id: f07d8bf89822d02a202ee81c78a17aa4b3e571cc
Diffstat (limited to 'c10')
-rw-r--r-- | c10/core/QScheme.h | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/c10/core/QScheme.h b/c10/core/QScheme.h index 4757a774ce..ab6a7005aa 100644 --- a/c10/core/QScheme.h +++ b/c10/core/QScheme.h @@ -1,5 +1,11 @@ #pragma once +#include <c10/core/TensorTypeId.h> +#include <c10/core/DeviceType.h> +// For kCPU +// TODO: Why are these defined in Backend.h? +#include <c10/core/Backend.h> + namespace c10 { /** @@ -8,17 +14,33 @@ namespace c10 { * Please refer to ATen/core/Quantizer.h to see the Quantizers classes. */ enum class QScheme : uint8_t { - NO_QUANT, - PER_TENSOR_AFFINE, - PER_CHANNEL_AFFINE, - PER_TENSOR_SYMMETRIC, - PER_CHANNEL_SYMMETRIC + PER_TENSOR_AFFINE = 0, + PER_CHANNEL_AFFINE = 1, + PER_TENSOR_SYMMETRIC = 2, + PER_CHANNEL_SYMMETRIC = 3, + COMPILE_TIME_NUM_QSCHEMES = 4, }; -constexpr auto kNoQuant = QScheme::NO_QUANT; 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 int COMPILE_TIME_NUM_QSCHEMES = + static_cast<int>(QScheme::COMPILE_TIME_NUM_QSCHEMES); + +inline std::string toString(QScheme qscheme) { + switch(qscheme) { + case kPerTensorAffine: + return "PerTensorAffine"; + case kPerChannelAffine: + return "PerChannelAffine"; + case kPerTensorSymmetric: + return "PerTensorSymmetric"; + case kPerChannelSymmetric: + return "PerChannelSymmetric"; + default: + AT_ERROR("Unrecognized qscheme: ", static_cast<int>(qscheme)); + } +} } // namespace c10 |