reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-10 c3765bd24fe73747688a0ec2a550f219c9acb384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
 
#include <c10/core/TensorTypeId.h>
#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,
  COMPILE_TIME_NUM_QSCHEMES = 4,
};
 
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 "per_tensor_affine";
    case kPerChannelAffine:
      return "per_channel_affine";
    case kPerTensorSymmetric:
      return "per_tensor_symmetric";
    case kPerChannelSymmetric:
      return "per_channel_symmetric";
    default:
      TORCH_CHECK(false, "Unrecognized qscheme: ", static_cast<int>(qscheme));
  }
}
 
} // namespace c10