Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ie_precision: added FloatTrait to fix VS2015 client compilation #5810

Merged
merged 1 commit into from
May 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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