Skip to content

Commit

Permalink
ie_precision: added FloatTrait to fix VS2015 client compilation (open…
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabunin authored and yekruglov committed Jun 7, 2021
1 parent d3c86f1 commit 1631afb
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions inference-engine/include/ie_precision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,72 +344,89 @@ struct PrecisionTrait {};
template <>
struct PrecisionTrait<Precision::FP32> {
using value_type = float;
enum { is_float = true };
};

template <>
struct PrecisionTrait<Precision::FP64> {
using value_type = double;
enum { is_float = true };
};

template <>
struct PrecisionTrait<Precision::FP16> {
using value_type = int16_t;
enum { is_float = true };
};
template <>
struct PrecisionTrait<Precision::BF16> {
using value_type = int16_t;
enum { is_float = true };
};
template<>
struct PrecisionTrait<Precision::Q78> {
using value_type = uint16_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::I16> {
using value_type = int16_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::U16> {
using value_type = uint16_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::U4> {
using value_type = uint8_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::U8> {
using value_type = uint8_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::I4> {
using value_type = int8_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::I8> {
using value_type = int8_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::BOOL> {
using value_type = uint8_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::I32> {
using value_type = int32_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::U32> {
using value_type = uint32_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::I64> {
using value_type = int64_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::U64> {
using value_type = uint64_t;
enum { is_float = false };
};
template <>
struct PrecisionTrait<Precision::BIN> {
using value_type = int8_t;
enum { is_float = false };
};

template <class T>
Expand All @@ -420,6 +437,7 @@ inline uint8_t type_size_or_zero() {
template <>
struct PrecisionTrait<Precision::UNSPECIFIED> {
using value_type = void;
enum { is_float = false };
};

template <>
Expand All @@ -430,32 +448,14 @@ inline uint8_t type_size_or_zero<void>() {
return 0;
}

namespace {
constexpr bool isSpecificFloatPrecision(const Precision::ePrecision& precision) {
return precision == Precision::FP16 || precision == Precision::BF16;
}
} // namespace

template <Precision::ePrecision T>
inline typename std::enable_if<isSpecificFloatPrecision(T), bool>::type
is_floating() {
return true;
}

template <Precision::ePrecision T>
inline typename std::enable_if<!isSpecificFloatPrecision(T), bool>::type
is_floating() {
return std::is_floating_point<typename PrecisionTrait<T>::value_type>::value;
}

template <Precision::ePrecision precision>
inline Precision::PrecisionInfo Precision::makePrecisionInfo(const char* name) {
Precision::PrecisionInfo info;
info.name = name;

size_t nBits = precision == BIN ? 1 : 8;
info.bitsSize = nBits * type_size_or_zero<typename PrecisionTrait<precision>::value_type>();
info.isFloat = is_floating<precision>();
info.isFloat = PrecisionTrait<precision>::is_float;
info.value = precision;
return info;
}
Expand Down

0 comments on commit 1631afb

Please sign in to comment.