#ifndef TENSORFLOW_FRAMEWORK_TYPE_TRAITS_H_ #define TENSORFLOW_FRAMEWORK_TYPE_TRAITS_H_ #include #include #include "tensorflow/core/framework/types.h" #include "tensorflow/core/platform/port.h" namespace tensorflow { // Functions to define quantization attribute of types. struct true_type { static const bool value = true; }; struct false_type { static const bool value = false; }; // Default is_quantized is false. template struct is_quantized : false_type {}; // Specialize the quantized types. template <> struct is_quantized : true_type {}; template <> struct is_quantized : true_type {}; template <> struct is_quantized : true_type {}; // All types not specialized are marked invalid. template struct IsValidDataType { static constexpr bool value = false; }; // Extra validity checking; not part of public API. struct TestIsValidDataType { static_assert(IsValidDataType::value, "Incorrect impl for int64"); static_assert(IsValidDataType::value, "Incorrect impl for int32"); }; } // namespace tensorflow // Define numeric limits for our quantized as subclasses of the // standard types. namespace std { template <> class numeric_limits : public numeric_limits {}; template <> class numeric_limits : public numeric_limits {}; template <> class numeric_limits : public numeric_limits {}; // Specialize is_signed for quantized types. template <> struct is_signed : public is_signed {}; template <> struct is_signed : public is_signed {}; template <> struct is_signed : public is_signed {}; } // namespace std #endif // TENSORFLOW_FRAMEWORK_TYPE_TRAITS_H_