From 6ddc47a7ef0a0a72e5d55511255ed7e39d46573e Mon Sep 17 00:00:00 2001 From: Vladislav Volkov Date: Thu, 16 Dec 2021 16:58:19 +0300 Subject: [PATCH] [CPU] Convert precisions on inputs/outputs (#8805) --- .../src/mkldnn_plugin/mkldnn_plugin.cpp | 31 +- .../nodes/common/cpu_convert.cpp | 616 ++++++++++++++++-- .../mkldnn_plugin/nodes/common/cpu_convert.h | 29 +- .../nodes/mkldnn_convert_node.cpp | 21 +- .../mkldnn_plugin/nodes/mkldnn_convert_node.h | 1 + .../python/tests/test_onnx/test_backend.py | 7 - .../python/tests/test_onnx/test_zoo_models.py | 6 - .../interface/ie_iplugin_internal.cpp | 16 +- .../blob_tests/set_blob.cpp | 11 +- .../single_layer_tests/conversion.cpp | 28 +- .../skip_tests_config.cpp | 24 +- .../ov_executable_network/exec_graph_info.hpp | 8 + .../plugin/shared/src/blob_tests/set_blob.cpp | 22 +- .../src/base/layer_test_utils.cpp | 84 +-- .../src/single_layer/conversion.cpp | 3 + 15 files changed, 725 insertions(+), 182 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp index 1c8b40aaa8b..a6bda152e23 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp @@ -504,23 +504,24 @@ Engine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, const std OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "Engine::LoadExeNetworkImpl"); // verification of supported input - InferenceEngine::InputsDataMap _networkInputs = network.getInputsInfo(); - for (const auto &ii : _networkInputs) { + for (const auto &ii : network.getInputsInfo()) { auto input_precision = ii.second->getPrecision(); - if (input_precision != InferenceEngine::Precision::FP64 && - input_precision != InferenceEngine::Precision::FP32 && - input_precision != InferenceEngine::Precision::I32 && - input_precision != InferenceEngine::Precision::U32 && - input_precision != InferenceEngine::Precision::U16 && - input_precision != InferenceEngine::Precision::I16 && - input_precision != InferenceEngine::Precision::I8 && - input_precision != InferenceEngine::Precision::U8 && - input_precision != InferenceEngine::Precision::BF16 && - input_precision != InferenceEngine::Precision::BOOL && - input_precision != InferenceEngine::Precision::I64 && - input_precision != InferenceEngine::Precision::U64) { + + using hash_t = std::hash::type>; + + static const std::unordered_set supported_precisions = { + Precision::U8, Precision::I8, + Precision::U16, Precision::I16, + Precision::U32, Precision::I32, + Precision::U64, Precision::I64, + Precision::BF16, Precision::FP16, + Precision::FP32, Precision::FP64, + Precision::BOOL + }; + + if (!supported_precisions.count(input_precision)) { IE_THROW(NotImplemented) - << "Input image format " << input_precision << " is not supported yet..."; + << "Input image format " << input_precision << " is not supported yet..."; } } diff --git a/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.cpp b/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.cpp index 8763b551af9..31205ad84e3 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.cpp @@ -4,27 +4,208 @@ #include "cpu_convert.h" #include "cpu_memcpy.h" -#include "utils/bfloat16.hpp" +#include +#include #include +#include +#include +#include +#include #include #include -#include +#include +using namespace MKLDNNPlugin; using namespace InferenceEngine; +using namespace dnnl::impl::cpu::x64; +using namespace dnnl::impl::utils; +using namespace Xbyak; namespace { -template -void convert(const void *srcPtr, void *dstPtr, const size_t size) { - if (std::is_same::value) { - cpu_memcpy(dstPtr, srcPtr, size*sizeof(dstType)); - } else { - const srcType *srcData = reinterpret_cast(srcPtr); - dstType *dstData = reinterpret_cast(dstPtr); +template +void convert_vec(jit_generator & gen, + const RegExp & src, + const RegExp & dst); - parallel_for(size, [&](size_t i) { - dstData[i] = static_cast(srcData[i]); +template <> +void convert_vec(jit_generator & gen, + const RegExp & src, + const RegExp & dst) { + auto const & f16vec = gen.xmm3; + auto const & f32vec = gen.ymm4; + + gen.movdqu(f16vec, gen.xword[src]); + gen.vcvtph2ps(f32vec, f16vec); + gen.vmovups(gen.yword[dst], f32vec); +} + +template <> +void convert_vec(jit_generator & gen, + const RegExp & src, + const RegExp & dst) { + auto const & f16vec = gen.xmm3; + auto const & f32vec = gen.ymm4; + + gen.vmovups(f32vec, gen.yword[src]); + gen.vcvtps2ph(f16vec, f32vec, 0); + gen.movdqu(gen.xword[dst], f16vec); +} + +class jit_convert_array : public jit_generator { + DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_convert_array) + + void generate() override { + const size_t vlen = 8u; + const size_t vlen_log2 = 3; + + auto reg_src = rax; + auto reg_dst = rbx; + auto reg_sz = rdx; + + Label tail, exit; + + preamble(); + + mov(reg_src, ptr[param1 + offsetof(args_t, src)]); + mov(reg_dst, ptr[param1 + offsetof(args_t, out)]); + mov(reg_sz, ptr[param1 + offsetof(args_t, count)]); + + xor_(rsi, rsi); + mov(r8, reg_sz); + shr(r8, vlen_log2); + + foreach(rsi, 1, r8, [&, this](const Xbyak::Reg64& idx) { + _convert_vec(*this, reg_src, reg_dst); + add(reg_src, _src_size * vlen); + add(reg_dst, _dst_size * vlen); }); + + L(tail); + + shl(rsi, vlen_log2); + sub(reg_sz, rsi); + test(reg_sz, reg_sz); + jz(exit); + + // allocate array for 8 floats on stack + sub(rsp, vlen * sizeof(float)); + mov(r8, rsp); + + vpxor(ymm4, ymm4, ymm4); + vmovups(yword[r8], ymm4); + + // Tail conversion + copy(r8, reg_src, reg_sz, _src_size); + _convert_vec(*this, r8, r8); + copy(reg_dst, r8, reg_sz, _dst_size); + + // Free the array on stack + add(rsp, vlen * sizeof(float)); + + L(exit); + + postamble(); + } + + void foreach(const Xbyak::Reg64& idx, + size_t step, + const Xbyak::Reg64& end, + std::function && fn) { + Label loop, exit; + + L(loop); + cmp(idx, end); + jge(exit); + + fn(idx); + + add(idx, step); + jmp(loop); + L(exit); + } + + void copy(const Xbyak::Reg64& dst, + const Xbyak::Reg64& src, + const Xbyak::Reg64& size, + size_t item_size) { + push(rsi); + push(r15); + + xor_(rsi, rsi); + + auto address_frame = [this](size_t size) -> const AddressFrame& { + switch (size) { + case 1: return byte; + case 2: return word; + case 4: return dword; + case 8: return qword; + default: + break; + } + return ptr; + }; + + const auto & addr_frame = address_frame(item_size); + + foreach(rsi, 1, size, [&, this](const Xbyak::Reg64& idx) { + mov(r15, addr_frame[src + idx * item_size]); + mov(addr_frame[dst + idx * item_size], r15); + }); + + pop(r15); + pop(rsi); + } + +public: + typedef struct { + const void* src; + void* out; + const size_t count; + } args_t; + + typedef void (*fn_t)(const args_t*); + + typedef void (*convert_vec_t)(jit_generator &, + const RegExp &, + const RegExp &); + + jit_convert_array(convert_vec_t convert_vec, + size_t src_size, + size_t dst_size) + : _convert_vec(convert_vec) + , _src_size(src_size) + , _dst_size(dst_size) {} + + template + static fn_t get() { + if (mayiuse(avx2) && cpu().has(util::Cpu::tF16C)) { + static jit_convert_array converter(convert_vec, sizeof(src_t), sizeof(dst_t)); + auto & generator = static_cast(converter); + generator.create_kernel(); + return (fn_t)generator.jit_ker(); + } + return nullptr; + } + +private: + convert_vec_t _convert_vec; + size_t _src_size; + size_t _dst_size; +}; + +template +void jit_convert(const TI* arg, TO* out, size_t count) { + using jit_impl = jit_convert_array; + static auto converter = jit_impl::get(); + + if (converter) { + typename jit_impl::args_t args = { arg, out, count }; + converter(&args); + } else { + for (size_t i = 0; i < count; ++i) { + out[i] = static_cast(arg[i]); + } } } @@ -35,84 +216,391 @@ struct PrecisionInfo { template <> struct PrecisionInfo { - using value_type = MKLDNNPlugin::bfloat16_t; + using value_type = bfloat16_t; }; +template <> +struct PrecisionInfo { + using value_type = ov::float16; +}; + +template <> +struct PrecisionInfo { + using value_type = uint8_t; +}; + +template::value + || std::is_same::value, + float, T>::type> +struct Range { + const std::tuple & fit(const Precision & prec); + +private: + std::tuple _range { + std::numeric_limits::lowest(), + std::numeric_limits::max() + }; +}; + +template +const std::tuple & Range::fit(const Precision & prec) { + if (prec.is_float()) { + double lbound, ubound; + switch (prec) { + case Precision::BF16: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::FP16: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::FP32: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::FP64: + lbound = std::numeric_limits::lowest(); + ubound = std::numeric_limits::max(); + break; + default: + IE_THROW() << "Unsupported precision"; + } + std::get<0>(_range) = static_cast(std::max(static_cast(std::get<0>(_range)), lbound)); + std::get<1>(_range) = static_cast(std::min(static_cast(std::get<1>(_range)), ubound)); + } else { + int64_t lbound; + uint64_t ubound; + switch (prec) { + case Precision::BOOL: + case Precision::U8: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::I8: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::U16: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::I16: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::U32: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::I32: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::U64: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + case Precision::I64: + lbound = static_cast(std::numeric_limits::lowest()); + ubound = static_cast(std::numeric_limits::max()); + break; + default: + IE_THROW() << "Unsupported precision"; + } + using ltype = typename std::conditional< + std::is_floating_point::value, + double, int64_t>::type; + using utype = typename std::conditional< + std::is_floating_point::value, + double, uint64_t>::type; + std::get<0>(_range) = static_cast(std::max(static_cast(std::get<0>(_range)), static_cast(lbound))); + std::get<1>(_range) = static_cast(std::min(static_cast(std::get<1>(_range)), static_cast(ubound))); + } + return _range; +} + struct ConvertContext { const void *srcPtr; void *dstPtr; size_t size; + Precision interimPrc; + Precision dstPrc; bool converted; + + template + std::tuple range() const { + Range r; + r.fit(interimPrc); + return r.fit(dstPrc); + } }; template -struct ConvertPrecision { - using src_t = typename std::tuple_element<0, T>::type; - using dst_t = typename std::tuple_element<1, T>::type; +struct ConvertPrecision; +template +struct ConvertPrecision> { void operator()(ConvertContext & ctx) { - convert(ctx.srcPtr, ctx.dstPtr, ctx.size); + auto src = static_cast(ctx.srcPtr); + auto dst = static_cast(ctx.dstPtr); + src_t lbound, ubound; + std::tie(lbound, ubound) = ctx.range(); + + if (std::is_integral::value + || ctx.interimPrc.is_float() + || std::is_integral::value) { + parallel_for(ctx.size, [&](size_t i) { + dst[i] = static_cast(std::max(std::min(src[i], ubound), lbound)); + }); + } else { + parallel_for(ctx.size, [&](size_t i) { + dst[i] = static_cast(std::trunc(std::max(std::min(src[i], ubound), lbound))); + }); + } + ctx.converted = true; } }; +template<> +struct ConvertPrecision> { + void operator()(ConvertContext & ctx) { + auto src = static_cast(ctx.srcPtr); + auto dst = static_cast(ctx.dstPtr); + + if (ctx.interimPrc.is_float()) { + parallel_for(ctx.size, [&](size_t i) { + dst[i] = static_cast(src[i]); + }); + } else { + float lbound, ubound; + std::tie(lbound, ubound) = ctx.range(); + parallel_for(ctx.size, [&](size_t i) { + dst[i] = static_cast(std::trunc(std::max(std::min(src[i], ubound), lbound))); + }); + } + + ctx.converted = true; + } +}; + +template<> +struct ConvertPrecision> { + void operator()(ConvertContext & ctx) { + auto src = static_cast(ctx.srcPtr); + auto dst = static_cast(ctx.dstPtr); + + if (ctx.interimPrc.is_float()) { + parallel_for(ctx.size, [&](size_t i) { + dst[i] = static_cast(src[i]); + }); + } else { + float lbound, ubound; + std::tie(lbound, ubound) = ctx.range(); + parallel_for(ctx.size, [&](size_t i) { + dst[i] = std::trunc(std::max(std::min(static_cast(src[i]), ubound), lbound)); + }); + } + + ctx.converted = true; + } +}; + +template +struct ConvertPrecision> { + void operator()(ConvertContext & ctx) { + auto src = static_cast(ctx.srcPtr); + auto dst = static_cast(ctx.dstPtr); + + constexpr size_t batch = 64; + const size_t iterations = MKLDNNPlugin::div_up(ctx.size, batch); + typedef float batch_type[batch]; + + src_t lbound, ubound; + std::tie(lbound, ubound) = ctx.range(); + + if (std::is_integral::value + || ctx.interimPrc.is_float()) { + parallel_for(iterations, [&](size_t i) { + batch_type tmp; + const size_t offset = i * batch; + const size_t current_batch_size = std::min(ctx.size - offset, batch); + for (size_t j = 0; j < current_batch_size; ++j) // src_t -> fp32 + tmp[j] = static_cast(std::max(std::min(src[offset + j], ubound), lbound)); + jit_convert(tmp, dst + offset, current_batch_size); // fp32 -> fp16 + }); + } else { + parallel_for(iterations, [&](size_t i) { + batch_type tmp; + const size_t offset = i * batch; + const size_t current_batch_size = std::min(ctx.size - offset, batch); + for (size_t j = 0; j < current_batch_size; ++j) // src_t -> fp32 + tmp[j] = static_cast(std::trunc(std::max(std::min(src[offset + j], ubound), lbound))); + jit_convert(tmp, dst + offset, current_batch_size); // fp32 -> fp16 + }); + } + + ctx.converted = true; + } +}; + +template +struct ConvertPrecision> { + void operator()(ConvertContext & ctx) { + auto src = static_cast(ctx.srcPtr); + auto dst = static_cast(ctx.dstPtr); + + constexpr size_t batch = 64; + const size_t iterations = MKLDNNPlugin::div_up(ctx.size, batch); + typedef float batch_type[batch]; + + float lbound, ubound; + std::tie(lbound, ubound) = ctx.range(); + + if (ctx.interimPrc.is_float() + || std::is_integral::value) { + parallel_for(iterations, [&](size_t i) { + batch_type tmp; + const size_t offset = i * batch; + const size_t current_batch_size = std::min(ctx.size - offset, batch); + jit_convert(src + offset, tmp, current_batch_size); // fp16 -> fp32 + for (size_t j = 0; j < current_batch_size; ++j) // fp32 -> dst_t + dst[offset + j] = static_cast(std::max(std::min(tmp[j], ubound), lbound)); + }); + } else { + parallel_for(iterations, [&](size_t i) { + batch_type tmp; + const size_t offset = i * batch; + const size_t current_batch_size = std::min(ctx.size - offset, batch); + jit_convert(src + offset, tmp, current_batch_size); // fp16 -> fp32 + for (size_t j = 0; j < current_batch_size; ++j) // fp32 -> dst_t + dst[offset + j] = static_cast(std::trunc(std::max(std::min(tmp[j], ubound), lbound))); + }); + } + + ctx.converted = true; + } +}; + +template<> +struct ConvertPrecision> { + void operator()(ConvertContext & ctx) { + auto src = static_cast(ctx.srcPtr); + auto dst = static_cast(ctx.dstPtr); + + constexpr size_t batch = 64; + const size_t iterations = MKLDNNPlugin::div_up(ctx.size, batch); + typedef float batch_type[batch]; + + float lbound, ubound; + std::tie(lbound, ubound) = ctx.range(); + + if (ctx.interimPrc.is_float()) { + cpu_memcpy(dst, src, ctx.size * sizeof(ov::float16)); + } else { + parallel_for(iterations, [&](size_t i) { + batch_type tmp; + const size_t offset = i * batch; + const size_t current_batch_size = std::min(ctx.size - offset, batch); + jit_convert(src + offset, tmp, current_batch_size); // fp16 -> fp32 + for (size_t j = 0; j < current_batch_size; ++j) // truncate fp32 + tmp[j] = std::trunc(std::max(std::min(tmp[j], ubound), lbound)); + jit_convert(tmp, dst + offset, current_batch_size); // fp32 -> fp16 + }); + } + + ctx.converted = true; + } +}; + +bool isConversionTruncatesRange(const Precision & from, const Precision & to) { + return to.bitsSize() < from.bitsSize() + || (from.is_float() && !to.is_float()) // float -> integral + || (from.isSigned() != to.isSigned()) // signed <-> unsigned + || (to == Precision::BOOL && from != to); // T -> bool +} + } // namespace #define MKLDNN_CVT(ST, DT) OV_CASE2(Precision::ST, Precision::DT, PrecisionInfo::value_type, PrecisionInfo::value_type) -void cpu_convert(const void *srcPtr, void *dstPtr, Precision srcPrc, Precision dstPrc, const size_t size) { - using namespace MKLDNNPlugin; +#define MKLDNN_CVT_LIST \ + MKLDNN_CVT(U8, I8), MKLDNN_CVT(U8, U16), MKLDNN_CVT(U8, I16), MKLDNN_CVT(U8, U32), \ + MKLDNN_CVT(U8, I32), MKLDNN_CVT(U8, U64), MKLDNN_CVT(U8, I64), MKLDNN_CVT(U8, FP32), \ + MKLDNN_CVT(U8, FP16), MKLDNN_CVT(U8, BF16), MKLDNN_CVT(U8, FP64), MKLDNN_CVT(U8, BOOL), \ + MKLDNN_CVT(I8, U8), MKLDNN_CVT(I8, U16), MKLDNN_CVT(I8, I16), MKLDNN_CVT(I8, U32), \ + MKLDNN_CVT(I8, I32), MKLDNN_CVT(I8, U64), MKLDNN_CVT(I8, I64), MKLDNN_CVT(I8, FP32), \ + MKLDNN_CVT(I8, FP16), MKLDNN_CVT(I8, BF16), MKLDNN_CVT(I8, FP64), MKLDNN_CVT(I8, BOOL), \ + MKLDNN_CVT(U16, U8), MKLDNN_CVT(U16, I8), MKLDNN_CVT(U16, I16), MKLDNN_CVT(U16, U32), \ + MKLDNN_CVT(U16, I32), MKLDNN_CVT(U16, U64), MKLDNN_CVT(U16, I64), MKLDNN_CVT(U16, FP32), \ + MKLDNN_CVT(U16, FP16), MKLDNN_CVT(U16, BF16), MKLDNN_CVT(U16, FP64), MKLDNN_CVT(U16, BOOL), \ + MKLDNN_CVT(I16, U8), MKLDNN_CVT(I16, I8), MKLDNN_CVT(I16, U16), MKLDNN_CVT(I16, U32), \ + MKLDNN_CVT(I16, I32), MKLDNN_CVT(I16, U64), MKLDNN_CVT(I16, I64), MKLDNN_CVT(I16, FP32), \ + MKLDNN_CVT(I16, FP16), MKLDNN_CVT(I16, BF16), MKLDNN_CVT(I16, FP64), MKLDNN_CVT(I16, BOOL), \ + MKLDNN_CVT(U32, U8), MKLDNN_CVT(U32, I8), MKLDNN_CVT(U32, U16), MKLDNN_CVT(U32, I16), \ + MKLDNN_CVT(U32, I32), MKLDNN_CVT(U32, U64), MKLDNN_CVT(U32, I64), MKLDNN_CVT(U32, FP32), \ + MKLDNN_CVT(U32, FP16), MKLDNN_CVT(U32, BF16), MKLDNN_CVT(U32, FP64), MKLDNN_CVT(U32, BOOL), \ + MKLDNN_CVT(I32, U8), MKLDNN_CVT(I32, I8), MKLDNN_CVT(I32, U16), MKLDNN_CVT(I32, I16), \ + MKLDNN_CVT(I32, U32), MKLDNN_CVT(I32, U64), MKLDNN_CVT(I32, I64), MKLDNN_CVT(I32, FP32), \ + MKLDNN_CVT(I32, FP16), MKLDNN_CVT(I32, BF16), MKLDNN_CVT(I32, FP64), MKLDNN_CVT(I32, BOOL), \ + MKLDNN_CVT(U64, U8), MKLDNN_CVT(U64, I8), MKLDNN_CVT(U64, U16), MKLDNN_CVT(U64, I16), \ + MKLDNN_CVT(U64, U32), MKLDNN_CVT(U64, I32), MKLDNN_CVT(U64, I64), MKLDNN_CVT(U64, FP32), \ + MKLDNN_CVT(U64, FP16), MKLDNN_CVT(U64, BF16), MKLDNN_CVT(U64, FP64), MKLDNN_CVT(U64, BOOL), \ + MKLDNN_CVT(I64, U8), MKLDNN_CVT(I64, I8), MKLDNN_CVT(I64, U16), MKLDNN_CVT(I64, I16), \ + MKLDNN_CVT(I64, U32), MKLDNN_CVT(I64, I32), MKLDNN_CVT(I64, U64), MKLDNN_CVT(I64, FP32), \ + MKLDNN_CVT(I64, FP16), MKLDNN_CVT(I64, BF16), MKLDNN_CVT(I64, FP64), MKLDNN_CVT(I64, BOOL), \ + MKLDNN_CVT(FP32, U8), MKLDNN_CVT(FP32, I8), MKLDNN_CVT(FP32, U16), MKLDNN_CVT(FP32, I16), \ + MKLDNN_CVT(FP32, U32), MKLDNN_CVT(FP32, I32), MKLDNN_CVT(FP32, U64), MKLDNN_CVT(FP32, I64), \ + MKLDNN_CVT(FP32, FP16), MKLDNN_CVT(FP32, BF16), MKLDNN_CVT(FP32, FP64), MKLDNN_CVT(FP32, BOOL), \ + MKLDNN_CVT(FP16, U8), MKLDNN_CVT(FP16, I8), MKLDNN_CVT(FP16, U16), MKLDNN_CVT(FP16, I16), \ + MKLDNN_CVT(FP16, U32), MKLDNN_CVT(FP16, I32), MKLDNN_CVT(FP16, U64), MKLDNN_CVT(FP16, I64), \ + MKLDNN_CVT(FP16, FP32), MKLDNN_CVT(FP16, BF16), MKLDNN_CVT(FP16, FP64), MKLDNN_CVT(FP16, BOOL), \ + MKLDNN_CVT(BF16, U8), MKLDNN_CVT(BF16, I8), MKLDNN_CVT(BF16, U16), MKLDNN_CVT(BF16, I16), \ + MKLDNN_CVT(BF16, U32), MKLDNN_CVT(BF16, I32), MKLDNN_CVT(BF16, U64), MKLDNN_CVT(BF16, I64), \ + MKLDNN_CVT(BF16, FP32), MKLDNN_CVT(BF16, FP16), MKLDNN_CVT(BF16, FP64), MKLDNN_CVT(BF16, BOOL), \ + MKLDNN_CVT(FP64, U8), MKLDNN_CVT(FP64, I8), MKLDNN_CVT(FP64, U16), MKLDNN_CVT(FP64, I16), \ + MKLDNN_CVT(FP64, U32), MKLDNN_CVT(FP64, I32), MKLDNN_CVT(FP64, U64), MKLDNN_CVT(FP64, I64), \ + MKLDNN_CVT(FP64, FP32), MKLDNN_CVT(FP64, FP16), MKLDNN_CVT(FP64, BF16), MKLDNN_CVT(FP64, BOOL), \ + MKLDNN_CVT(BOOL, U8), MKLDNN_CVT(BOOL, I8), MKLDNN_CVT(BOOL, U16), MKLDNN_CVT(BOOL, I16), \ + MKLDNN_CVT(BOOL, U32), MKLDNN_CVT(BOOL, I32), MKLDNN_CVT(BOOL, U64), MKLDNN_CVT(BOOL, I64), \ + MKLDNN_CVT(BOOL, FP32), MKLDNN_CVT(BOOL, FP16), MKLDNN_CVT(BOOL, BF16), MKLDNN_CVT(BOOL, FP64), \ + MKLDNN_CVT(U8, U8), MKLDNN_CVT(I8, I8), MKLDNN_CVT(U16, U16), MKLDNN_CVT(I16, I16), \ + MKLDNN_CVT(U32, U32), MKLDNN_CVT(I32, I32), MKLDNN_CVT(U64, U64), MKLDNN_CVT(I64, I64), \ + MKLDNN_CVT(FP32, FP32), MKLDNN_CVT(FP16, FP16), MKLDNN_CVT(BF16, BF16), MKLDNN_CVT(FP64, FP64), \ + MKLDNN_CVT(BOOL, BOOL) +void cpu_convert(const void *srcPtr, void *dstPtr, Precision srcPrc, Precision dstPrc, const size_t size) { + cpu_convert(srcPtr, dstPtr, srcPrc, dstPrc, dstPrc, size); +} + +void cpu_convert(const void *srcPtr, + void *dstPtr, + InferenceEngine::Precision srcPrc, + InferenceEngine::Precision interimPrc, + InferenceEngine::Precision dstPrc, + const size_t size) { if (srcPtr == nullptr || dstPtr == nullptr) IE_THROW() << "cpu_convert has null data pointer"; - if (srcPrc == dstPrc) { - cpu_memcpy(dstPtr, srcPtr, size*dstPrc.size()); - return; + if (srcPrc == dstPrc && srcPrc == interimPrc) { + cpu_memcpy(dstPtr, srcPtr, size * dstPrc.size()); + } else { + ConvertContext ctx = { + srcPtr, + dstPtr, + size, + interimPrc, + dstPrc, + false + }; + OV_SWITCH(MKLDNNPlugin, ConvertPrecision, ctx, std::tie(srcPrc, dstPrc), MKLDNN_CVT_LIST); + if (!ctx.converted) + IE_THROW() << "cpu_convert can't convert from: " << srcPrc << " precision to: " << dstPrc; } - - ConvertContext ctx = { srcPtr, dstPtr, size, false }; - - OV_SWITCH(MKLDNNPlugin, ConvertPrecision, ctx, std::tie(srcPrc, dstPrc), - MKLDNN_CVT(U8, I8), MKLDNN_CVT(U8, U16), MKLDNN_CVT(U8, I16), - MKLDNN_CVT(U8, I32), MKLDNN_CVT(U8, U64), MKLDNN_CVT(U8, I64), - MKLDNN_CVT(U8, FP32), MKLDNN_CVT(U8, BF16), MKLDNN_CVT(U8, BOOL), - MKLDNN_CVT(I8, U8), MKLDNN_CVT(I8, U16), MKLDNN_CVT(I8, I16), - MKLDNN_CVT(I8, I32), MKLDNN_CVT(I8, U64), MKLDNN_CVT(I8, I64), - MKLDNN_CVT(I8, FP32), MKLDNN_CVT(I8, BF16), MKLDNN_CVT(I8, BOOL), - MKLDNN_CVT(U16, U8), MKLDNN_CVT(U16, I8), MKLDNN_CVT(U16, I16), - MKLDNN_CVT(U16, I32), MKLDNN_CVT(U16, U64), MKLDNN_CVT(U16, I64), - MKLDNN_CVT(U16, FP32), MKLDNN_CVT(U16, BF16), MKLDNN_CVT(U16, BOOL), - MKLDNN_CVT(I16, U8), MKLDNN_CVT(I16, I8), MKLDNN_CVT(I16, U16), - MKLDNN_CVT(I16, I32), MKLDNN_CVT(I16, U64), MKLDNN_CVT(I16, I64), - MKLDNN_CVT(I16, FP32), MKLDNN_CVT(I16, BF16), MKLDNN_CVT(I16, BOOL), - MKLDNN_CVT(I32, U8), MKLDNN_CVT(I32, I8), MKLDNN_CVT(I32, U16), - MKLDNN_CVT(I32, I16), MKLDNN_CVT(I32, U64), MKLDNN_CVT(I32, I64), - MKLDNN_CVT(I32, FP32), MKLDNN_CVT(I32, BF16), MKLDNN_CVT(I32, BOOL), - MKLDNN_CVT(U64, U8), MKLDNN_CVT(U64, I8), MKLDNN_CVT(U64, U16), - MKLDNN_CVT(U64, I16), MKLDNN_CVT(U64, I32), MKLDNN_CVT(U64, I64), - MKLDNN_CVT(U64, FP32), MKLDNN_CVT(U64, BF16), MKLDNN_CVT(U64, BOOL), - MKLDNN_CVT(I64, U8), MKLDNN_CVT(I64, I8), MKLDNN_CVT(I64, U16), - MKLDNN_CVT(I64, I16), MKLDNN_CVT(I64, I32), MKLDNN_CVT(I64, U64), - MKLDNN_CVT(I64, FP32), MKLDNN_CVT(I64, BF16), MKLDNN_CVT(I64, BOOL), - MKLDNN_CVT(FP32, U8), MKLDNN_CVT(FP32, I8), MKLDNN_CVT(FP32, U16), - MKLDNN_CVT(FP32, I16), MKLDNN_CVT(FP32, I32), MKLDNN_CVT(FP32, U64), - MKLDNN_CVT(FP32, I64), MKLDNN_CVT(FP32, BF16), MKLDNN_CVT(FP32, BOOL), - MKLDNN_CVT(BF16, U8), MKLDNN_CVT(BF16, I8), MKLDNN_CVT(BF16, U16), - MKLDNN_CVT(BF16, I16), MKLDNN_CVT(BF16, I32), MKLDNN_CVT(BF16, U64), - MKLDNN_CVT(BF16, I64), MKLDNN_CVT(BF16, FP32), MKLDNN_CVT(BF16, BOOL), - MKLDNN_CVT(BOOL, U8), MKLDNN_CVT(BOOL, I8), MKLDNN_CVT(BOOL, U16), - MKLDNN_CVT(BOOL, I16), MKLDNN_CVT(BOOL, I32), MKLDNN_CVT(BOOL, U64), - MKLDNN_CVT(BOOL, I64), MKLDNN_CVT(BOOL, FP32), MKLDNN_CVT(BOOL, BF16), - MKLDNN_CVT(FP64, U8), MKLDNN_CVT(FP64, I8), MKLDNN_CVT(FP64, U16), - MKLDNN_CVT(FP64, I16), MKLDNN_CVT(FP64, I32), MKLDNN_CVT(FP64, U64), - MKLDNN_CVT(FP64, I64), MKLDNN_CVT(FP64, FP32), MKLDNN_CVT(FP64, BF16), MKLDNN_CVT(FP64, BOOL), - MKLDNN_CVT(U32, U8), MKLDNN_CVT(U32, I8), MKLDNN_CVT(U32, U16), - MKLDNN_CVT(U32, I16), MKLDNN_CVT(U32, I32), MKLDNN_CVT(U32, U64), - MKLDNN_CVT(U32, I64), MKLDNN_CVT(U32, FP32), MKLDNN_CVT(U32, BF16), MKLDNN_CVT(U32, BOOL)); - - if (!ctx.converted) - IE_THROW() << "cpu_convert can't convert from: " << srcPrc << " precision to: " << dstPrc; } #undef MKLDNN_CVT +#undef MKLDNN_CVT_LIST diff --git a/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.h b/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.h index dd4ef59a38b..8ed46cab7a0 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.h +++ b/inference-engine/src/mkldnn_plugin/nodes/common/cpu_convert.h @@ -19,5 +19,32 @@ * number of elements in buffers to be converted * @return none. */ +void cpu_convert(const void *srcPtr, + void *dstPtr, + InferenceEngine::Precision srcPrc, + InferenceEngine::Precision dstPrc, + const size_t size); -void cpu_convert(const void *srcPtr, void *dstPtr, InferenceEngine::Precision srcPrc, InferenceEngine::Precision dstPrc, const size_t size); +/** + * @brief Copy size elements from buffer specified srcPtr pointer to buffer specified dstPtr. + * If the precisions srcPrc and dstPrc are different, a conversion from srcPrc to dstPrc is performed. + * @param srcPtr + * pointer to the buffer to convert from + * @param dstPtr + * pointer to the buffer to convert to + * @param srcPrc + * precision the buffer from which convert + * @param interimPrc + * intermediate precision used for type truncation + * @param dstPrc + * precision the buffer to which convert + * @param size + * number of elements in buffers to be converted + * @return none. + */ +void cpu_convert(const void *srcPtr, + void *dstPtr, + InferenceEngine::Precision srcPrc, + InferenceEngine::Precision interimPrc, + InferenceEngine::Precision dstPrc, + const size_t size); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp index 2faf969c1ea..2a20f45ff29 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp @@ -7,7 +7,8 @@ #include "common/cpu_convert.h" #include "common/blocked_desc_creator.h" #include -#include "utils/ngraph_utils.hpp" +#include +#include using namespace mkldnn; using namespace MKLDNNPlugin; @@ -26,14 +27,17 @@ bool MKLDNNConvertNode::isSupportedOperation(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) : - MKLDNNNode(op, eng, cache) { +MKLDNNConvertNode::MKLDNNConvertNode(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) + : MKLDNNNode(op, eng, cache) { std::string errorMessage; if (isSupportedOperation(op, errorMessage)) { errorPrefix = "Convert node with name '" + getName() + "'"; } else { IE_THROW(NotImplemented) << errorMessage; } + + auto convert = ov::as_type_ptr(op); + origPrc = details::convertPrecision(convert->get_destination_type()); } std::vector MKLDNNConvertNode::shapeInfer() const { @@ -42,7 +46,8 @@ std::vector MKLDNNConvertNode::shapeInfer() const { MKLDNNConvertNode::MKLDNNConvertNode(const Shape &shape, const InferenceEngine::Precision &inPrc, const InferenceEngine::Precision &outPrc, const std::string &nodeName, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) - : MKLDNNNode("Convert", nodeName, eng, cache) { + : MKLDNNNode("Convert", nodeName, eng, cache) + , origPrc(outPrc) { inputShapes.push_back(shape); addOriginalInputPrecision(inPrc); outputShapes.push_back(shape); @@ -147,7 +152,13 @@ void MKLDNNConvertNode::execute(mkldnn::stream strm) { void* srcPtr = parentMem.GetPtr(); void* dstPtr = childMem.GetPtr(); - cpu_convert(srcPtr, dstPtr, parentMem.getDesc().getPrecision(), childMem.getDesc().getPrecision(), parentPaddElemCount); + + cpu_convert(srcPtr, + dstPtr, + parentMem.getDesc().getPrecision(), + origPrc, + childMem.getDesc().getPrecision(), + parentPaddElemCount); } bool MKLDNNConvertNode::created() const { diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h index bffb2447280..08042187788 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h @@ -49,6 +49,7 @@ public: private: MemoryDescPtr input; MemoryDescPtr output; + InferenceEngine::Precision origPrc; std::string errorPrefix; }; diff --git a/src/bindings/python/tests/test_onnx/test_backend.py b/src/bindings/python/tests/test_onnx/test_backend.py index a3f88676852..7385c5057ef 100644 --- a/src/bindings/python/tests/test_onnx/test_backend.py +++ b/src/bindings/python/tests/test_onnx/test_backend.py @@ -101,16 +101,9 @@ tests_expected_to_fail = [ ( xfail_issue_FLOAT_LIKE, "OnnxBackendNodeModelTest.test_cast_BFLOAT16_to_FLOAT_cpu", - "OnnxBackendNodeModelTest.test_cast_FLOAT16_to_DOUBLE_cpu", - "OnnxBackendNodeModelTest.test_cast_FLOAT16_to_FLOAT_cpu", "OnnxBackendNodeModelTest.test_cast_FLOAT_to_BFLOAT16_cpu", "OnnxBackendNodeModelTest.test_castlike_BFLOAT16_to_FLOAT_expanded_cpu", - "OnnxBackendNodeModelTest.test_castlike_FLOAT16_to_DOUBLE_expanded_cpu", - "OnnxBackendNodeModelTest.test_castlike_FLOAT16_to_FLOAT_expanded_cpu", "OnnxBackendNodeModelTest.test_castlike_FLOAT_to_BFLOAT16_expanded_cpu", - "OnnxBackendNodeModelTest.test_max_float16_cpu", - "OnnxBackendNodeModelTest.test_min_float16_cpu", - "OnnxBackendNodeModelTest.test_mod_mixed_sign_float16_cpu", ), ( xfail_issue_49207, diff --git a/src/bindings/python/tests/test_onnx/test_zoo_models.py b/src/bindings/python/tests/test_onnx/test_zoo_models.py index ee16fa4724a..ac455d76168 100644 --- a/src/bindings/python/tests/test_onnx/test_zoo_models.py +++ b/src/bindings/python/tests/test_onnx/test_zoo_models.py @@ -171,12 +171,6 @@ if len(zoo_models) > 0: test_cases = backend_test.test_cases["OnnxBackendModelExecutionTest"] if tests.MODEL_ZOO_XFAIL: execution_xfail_list = [ - # New Python API - fp16 blob - (xfail_issue_67415, "test_MSFT_opset7_fp16_inception_v1_onnxzoo_lotus_inception_v1_cpu"), - (xfail_issue_67415, "test_MSFT_opset7_fp16_shufflenet_onnxzoo_lotus_shufflenet_cpu"), - (xfail_issue_67415, "test_MSFT_opset8_fp16_inception_v1_onnxzoo_lotus_inception_v1_cpu"), - (xfail_issue_67415, "test_MSFT_opset8_fp16_shufflenet_onnxzoo_lotus_shufflenet_cpu"), - # ONNX Model Zoo (xfail_issue_39669, "test_onnx_model_zoo_text_machine_comprehension_t5_model_t5_encoder_12_t5_encoder_cpu"), (xfail_issue_39669, "test_onnx_model_zoo_text_machine_comprehension_t5_model_t5_decoder_with_lm_head_12_t5_decoder_with_lm_head_cpu"), diff --git a/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp b/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp index a3f27eb8ea2..945f06ef6e8 100644 --- a/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp +++ b/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp @@ -309,16 +309,15 @@ void IInferencePlugin::SetExeNetworkInfo(const std::shared_ptrget_output_size()); for (const auto& param : function->get_parameters()) { - auto new_param = param->copy_with_new_inputs({}); + auto new_param = ov::as_type_ptr(param->copy_with_new_inputs({})); new_param->set_friendly_name(param->get_friendly_name()); if (add_operation_names) new_param->output(0).get_tensor().add_names({new_param->get_friendly_name()}); // WA: use CNNNetwork's precisions since plugins sometimes override their precisions // after transformation pipeline is run - new_param->set_output_type( - 0, - InferenceEngine::details::convertPrecision(inputsInfo.at(new_param->get_friendly_name())->getPrecision()), - new_param->get_output_partial_shape(0)); + new_param->set_element_type( + InferenceEngine::details::convertPrecision(inputsInfo.at(new_param->get_friendly_name())->getPrecision())); + new_param->validate_and_infer_types(); const_params.emplace_back(new_param); } for (const auto& result : function->get_results()) { @@ -326,10 +325,9 @@ void IInferencePlugin::SetExeNetworkInfo(const std::shared_ptrget_output_partial_shape(0)); const std::string param_name = ngraph::op::util::create_ie_output_name(result->input_value(0)); fake_param->set_friendly_name(param_name); - fake_param->set_output_type( - 0, - InferenceEngine::details::convertPrecision(outputsInfo.at(param_name)->getPrecision()), - fake_param->get_output_partial_shape(0)); + fake_param->set_element_type( + InferenceEngine::details::convertPrecision(outputsInfo.at(param_name)->getPrecision())); + fake_param->validate_and_infer_types(); auto new_result = result->copy_with_new_inputs({fake_param}); new_result->set_friendly_name(result->get_friendly_name()); if (add_operation_names) { diff --git a/src/tests/functional/plugin/cpu/shared_tests_instances/blob_tests/set_blob.cpp b/src/tests/functional/plugin/cpu/shared_tests_instances/blob_tests/set_blob.cpp index 5e27ee86b77..641d25dacb8 100644 --- a/src/tests/functional/plugin/cpu/shared_tests_instances/blob_tests/set_blob.cpp +++ b/src/tests/functional/plugin/cpu/shared_tests_instances/blob_tests/set_blob.cpp @@ -8,8 +8,15 @@ using namespace BehaviorTestsDefinitions; using namespace InferenceEngine; -const std::vector precisionSet = {Precision::FP32, Precision::I16, Precision::U8, Precision::I8, Precision::U16, Precision::I32, Precision::BOOL, - Precision::I64, Precision::U64}; +const std::vector precisionSet = { + Precision::U8, Precision::I8, + Precision::U16, Precision::I16, + Precision::U32, Precision::I32, + Precision::U64, Precision::I64, + Precision::BF16, Precision::FP16, + Precision::FP32, Precision::FP64, + Precision::BOOL +}; const std::vector typeSet = {setType::INPUT, setType::OUTPUT, setType::BOTH}; diff --git a/src/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/conversion.cpp b/src/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/conversion.cpp index 03be6f86285..868f22db789 100644 --- a/src/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/conversion.cpp +++ b/src/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/conversion.cpp @@ -18,24 +18,26 @@ const std::vector conversionOpTypes = { const std::vector> inShape = {{1, 2, 3, 4}}; const std::vector netPrecisions = { - // Ticket: 59594 - // InferenceEngine::Precision::I4, - InferenceEngine::Precision::I8, - InferenceEngine::Precision::I16, - InferenceEngine::Precision::I32, - InferenceEngine::Precision::I64, - // Ticket: 59594 - // InferenceEngine::Precision::BIN, - // InferenceEngine::Precision::BOOL, - // InferenceEngine::Precision::U4, InferenceEngine::Precision::U8, + InferenceEngine::Precision::I8, InferenceEngine::Precision::U16, - // Ticket: 59594 - // InferenceEngine::Precision::U32, + InferenceEngine::Precision::I16, + InferenceEngine::Precision::U32, + InferenceEngine::Precision::I32, InferenceEngine::Precision::U64, + InferenceEngine::Precision::I64, InferenceEngine::Precision::BF16, InferenceEngine::Precision::FP16, - InferenceEngine::Precision::FP32}; + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP64, + InferenceEngine::Precision::BOOL, + InferenceEngine::Precision::MIXED, + InferenceEngine::Precision::Q78, + InferenceEngine::Precision::U4, + InferenceEngine::Precision::I4, + InferenceEngine::Precision::BIN, + InferenceEngine::Precision::CUSTOM, +}; INSTANTIATE_TEST_SUITE_P(smoke_ConversionLayerTest, ConversionLayerTest, diff --git a/src/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/src/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index e9d0e22bc4e..b6857ff3671 100644 --- a/src/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/src/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -104,17 +104,6 @@ std::vector disabledTestPatterns() { // CPU plugin does not support some precisions R"(smoke_CachingSupportCase_CPU/LoadNetworkCacheTestBase.CompareWithRefImpl/ReadConcatSplitAssign_f32_batch1_CPU)", - // CPU plugin does not support some precisions - R"(.*Behavior.*OVExecGraphImportExportTest.*elementType=(i8|u32).*)", - R"(.*Behavior.*OVExecGraphImportExportTest.*elementType=(f16).*)", - R"(.*EltwiseLayerTest.*NetType=f16.*)", - - // TODO: CVS-66526 overrides i/o precisions in execution graph - // as WA we used GetInputsInfo() precisions instead of ngraph ones - // R"(.*smoke_BehaviorTests.*OVExecGraphImportExportTest.*importExportedFunction.*type=(i16|u16).*)", - // R"(.*smoke_BehaviorTests.*OVExecGraphImportExportTest.*importExportedFunction.*type=(i64|u64).*)", - // R"(.*smoke_BehaviorTests.*OVExecGraphImportExportTest.*importExportedIENetwork.*type=(i16|u16).*)", - // R"(.*smoke_BehaviorTests.*OVExecGraphImportExportTest.*importExportedIENetwork.*type=(i64|u64).*)", // CPU does not support dynamic rank // Issue: CVS-66778 @@ -168,7 +157,18 @@ std::vector disabledTestPatterns() { R"(.*CTCLossLayerCPUTest.*ctcMergeRepeated=1.*)", // Issue: 71756 R"(.*Deconv_.*D_(Blocked|DW|1x1)_.*DeconvolutionLayerCPUTest\.CompareWithRefs.*inFmts=(nChw16c|nCdhw16c)_outFmts=(nChw16c|nCdhw16c)_primitive=jit_avx512_.*Fused=Multiply\(PerChannel\)\.Add\(PerChannel\).*)", - R"(.*smoke_GroupDeconv_(2|3)D_Blocked_BF16.*S=(\(2\.2\)|\(2\.2\.2\))_PB=(\(0\.0\)|\(0\.0\.0\))_PE=(\(0\.0\)|\(0\.0\.0\))_D=(\(1\.1\)|\(1\.1\.1\))_.*_O=64_G=4.*)" + R"(.*smoke_GroupDeconv_(2|3)D_Blocked_BF16.*S=(\(2\.2\)|\(2\.2\.2\))_PB=(\(0\.0\)|\(0\.0\.0\))_PE=(\(0\.0\)|\(0\.0\.0\))_D=(\(1\.1\)|\(1\.1\.1\))_.*_O=64_G=4.*)", + // Issue: 72150 + R"(.*smoke_SetBlobCPU/SetBlobTest.CompareWithRefs/Type=.*_Device=CPU_PrecisionInNet=BOOL.*)", + // Issue: 59594 + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*BOOL.*)", + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*MIXED.*)", + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*Q78.*)", + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*U4.*)", + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*I4.*)", + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*BIN.*)", + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*CUSTOM.*)", + R"(smoke_ConversionLayerTest/ConversionLayerTest.CompareWithRefs.*UNSPECIFIED.*)", }; #define FIX_62820 0 diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp index 65aac7c4766..2478213bd7d 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp @@ -108,11 +108,15 @@ TEST_P(OVExecGraphImportExportTest, importExportedFunction) { importedExecNet.input(0).get_tensor().get_partial_shape()); EXPECT_EQ(function->input(0).get_tensor().get_element_type(), importedExecNet.input(0).get_tensor().get_element_type()); + EXPECT_EQ(function->input(0).get_element_type(), + importedExecNet.input(0).get_tensor().get_element_type()); EXPECT_EQ(function->input(1).get_tensor().get_names(), importedExecNet.input(1).get_tensor().get_names()); EXPECT_EQ(function->input(1).get_tensor().get_partial_shape(), importedExecNet.input(1).get_tensor().get_partial_shape()); EXPECT_EQ(function->input(1).get_tensor().get_element_type(), importedExecNet.input(1).get_tensor().get_element_type()); + EXPECT_EQ(function->input(1).get_element_type(), + importedExecNet.input(1).get_tensor().get_element_type()); EXPECT_EQ(importedExecNet.input(0).get_node(), importedExecNet.input("data1").get_node()); EXPECT_NE(importedExecNet.input(1).get_node(), importedExecNet.input("data1").get_node()); EXPECT_EQ(importedExecNet.input(1).get_node(), importedExecNet.input("data2").get_node()); @@ -125,11 +129,15 @@ TEST_P(OVExecGraphImportExportTest, importExportedFunction) { importedExecNet.output(0).get_tensor().get_partial_shape()); EXPECT_EQ(function->output(0).get_tensor().get_element_type(), importedExecNet.output(0).get_tensor().get_element_type()); + EXPECT_EQ(function->output(0).get_element_type(), + importedExecNet.output(0).get_tensor().get_element_type()); EXPECT_EQ(function->output(1).get_tensor().get_names(), importedExecNet.output(1).get_tensor().get_names()); EXPECT_EQ(function->output(1).get_tensor().get_partial_shape(), importedExecNet.output(1).get_tensor().get_partial_shape()); EXPECT_EQ(function->output(1).get_tensor().get_element_type(), importedExecNet.output(1).get_tensor().get_element_type()); + EXPECT_EQ(function->output(1).get_element_type(), + importedExecNet.output(1).get_tensor().get_element_type()); EXPECT_EQ(importedExecNet.output(0).get_node(), importedExecNet.output("relu").get_node()); EXPECT_NE(importedExecNet.output(1).get_node(), importedExecNet.output("relu").get_node()); EXPECT_EQ(importedExecNet.output(1).get_node(), importedExecNet.output("concat").get_node()); diff --git a/src/tests/functional/plugin/shared/src/blob_tests/set_blob.cpp b/src/tests/functional/plugin/shared/src/blob_tests/set_blob.cpp index 073b78c66c5..ad8e0555683 100644 --- a/src/tests/functional/plugin/shared/src/blob_tests/set_blob.cpp +++ b/src/tests/functional/plugin/shared/src/blob_tests/set_blob.cpp @@ -43,15 +43,19 @@ std::string SetBlobTest::getTestCaseName(testing::TestParamInfo o inline void fillBlob(Blob::Ptr &blob) { switch (blob->getTensorDesc().getPrecision()) { #define CASE(X) case X: CommonTestUtils::fill_data_random(blob); break; - CASE(InferenceEngine::Precision::FP32) - CASE(InferenceEngine::Precision::U8) - CASE(InferenceEngine::Precision::U16) - CASE(InferenceEngine::Precision::I8) - CASE(InferenceEngine::Precision::I16) - CASE(InferenceEngine::Precision::I64) - CASE(InferenceEngine::Precision::U64) - CASE(InferenceEngine::Precision::I32) - CASE(InferenceEngine::Precision::BOOL) + CASE(Precision::U8) + CASE(Precision::I8) + CASE(Precision::U16) + CASE(Precision::I16) + CASE(Precision::U32) + CASE(Precision::I32) + CASE(Precision::U64) + CASE(Precision::I64) + CASE(Precision::BF16) + CASE(Precision::FP16) + CASE(Precision::FP32) + CASE(Precision::FP64) + CASE(Precision::BOOL) #undef CASE default: IE_THROW() << "Can't fill blob with precision: " << blob->getTensorDesc().getPrecision(); diff --git a/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp b/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp index 67dc3d5cb2c..7292ae0eb78 100644 --- a/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp +++ b/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp @@ -131,54 +131,54 @@ inline void callCompare(const std::pair(reinterpret_cast(expectedBuffer), - actualBuffer, size, threshold, abs_threshold); - break; - case ngraph::element::Type_t::i32: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, size, threshold, abs_threshold); - break; - case ngraph::element::Type_t::i16: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + case ngraph::element::Type_t::boolean: + case ngraph::element::Type_t::u8: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), actualBuffer, size, threshold, abs_threshold); break; case ngraph::element::Type_t::i8: LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), actualBuffer, size, threshold, abs_threshold); break; - case ngraph::element::Type_t::u64: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + case ngraph::element::Type_t::u16: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), actualBuffer, size, threshold, abs_threshold); break; + case ngraph::element::Type_t::i16: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + actualBuffer, size, threshold, abs_threshold); + break; case ngraph::element::Type_t::u32: LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), actualBuffer, size, threshold, abs_threshold); break; - case ngraph::element::Type_t::u16: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, size, threshold, abs_threshold); - break; - case ngraph::element::Type_t::boolean: - case ngraph::element::Type_t::u8: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + case ngraph::element::Type_t::i32: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), actualBuffer, size, threshold, abs_threshold); break; - case ngraph::element::Type_t::f64: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, size, threshold, abs_threshold); + case ngraph::element::Type_t::u64: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + actualBuffer, size, threshold, abs_threshold); break; - case ngraph::element::Type_t::f32: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, size, threshold, abs_threshold); + case ngraph::element::Type_t::i64: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + actualBuffer, size, threshold, abs_threshold); + break; + case ngraph::element::Type_t::bf16: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + actualBuffer, size, threshold, abs_threshold); break; case ngraph::element::Type_t::f16: LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), actualBuffer, size, threshold, abs_threshold); break; - case ngraph::element::Type_t::bf16: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, size, threshold, abs_threshold); + case ngraph::element::Type_t::f32: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + actualBuffer, size, threshold, abs_threshold); + break; + case ngraph::element::Type_t::f64: + LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), + actualBuffer, size, threshold, abs_threshold); break; case ngraph::element::Type_t::i4: { auto expectedOut = ngraph::helpers::convertOutputPrecision( @@ -230,14 +230,9 @@ void LayerTestsCommon::Compare(const std::pairsize(); switch (precision) { - case InferenceEngine::Precision::FP32: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::I32: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::I64: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); + case InferenceEngine::Precision::BOOL: + case InferenceEngine::Precision::U8: + callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); break; case InferenceEngine::Precision::I8: callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); @@ -248,19 +243,30 @@ void LayerTestsCommon::Compare(const std::pair(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); break; - case InferenceEngine::Precision::BOOL: - case InferenceEngine::Precision::U8: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); + case InferenceEngine::Precision::U32: + callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); + break; + case InferenceEngine::Precision::I32: + callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); break; case InferenceEngine::Precision::U64: callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); break; + case InferenceEngine::Precision::I64: + callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); + break; case InferenceEngine::Precision::BF16: callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); break; case InferenceEngine::Precision::FP16: callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); break; + case InferenceEngine::Precision::FP32: + callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); + break; + case InferenceEngine::Precision::FP64: + callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); + break; default: FAIL() << "Comparator for " << precision << " precision isn't supported"; } diff --git a/src/tests/functional/shared_test_classes/src/single_layer/conversion.cpp b/src/tests/functional/shared_test_classes/src/single_layer/conversion.cpp index 0c5e7a387a7..1320abbd362 100644 --- a/src/tests/functional/shared_test_classes/src/single_layer/conversion.cpp +++ b/src/tests/functional/shared_test_classes/src/single_layer/conversion.cpp @@ -28,6 +28,9 @@ std::string ConversionLayerTest::getTestCaseName(const testing::TestParamInfo> inputShape;