Skip to content

Commit

Permalink
[CPU Plugin 2.0] replace ie::precision with ov::element (openvinotool…
Browse files Browse the repository at this point in the history
…kit#21041)

* [CPU Plugin 2.0] replace ie::precision with ov::element

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin 2.0] fix MatmulWeightsDecompression.CompareWithRefs test error

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin 2.0] fix compiler error

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin 2.0] fix compiler error

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin 2.0] fix review comment

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

---------

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
  • Loading branch information
zhaixuejun1993 authored Nov 15, 2023
1 parent 0180078 commit 66a8600
Show file tree
Hide file tree
Showing 238 changed files with 2,383 additions and 2,280 deletions.
2 changes: 1 addition & 1 deletion src/plugins/intel_cpu/src/cpu_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace {
if (!ftz) {
return;
}
if (src.getDesc().getPrecision() != Precision::FP32 || dst.getDesc().getPrecision() == Precision::BF16) {
if (src.getDesc().getPrecision() != ov::element::f32 || dst.getDesc().getPrecision() == ov::element::bf16) {
return;
}
size_t offset = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/intel_cpu/src/cpu_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <functional>
#include <memory>
#include <vector>
#include <ie_precision.hpp>

/**
* @file contains a concept classes to work with memory/tensor/blob abstractions on plugin level.
Expand Down Expand Up @@ -187,7 +186,7 @@ class IMemory {
//oneDNN specifics for backward compatibility
virtual dnnl::memory getPrimitive() const = 0;
dnnl::memory::data_type getDataType() const {
return DnnlExtensionUtils::IEPrecisionToDataType(getDesc().getPrecision());
return DnnlExtensionUtils::ElementTypeToDataType(getDesc().getPrecision());
}

virtual void nullify() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_cpu/src/cpu_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Tensor::Tensor(MemoryPtr memptr) : m_memptr{memptr} {
auto memdesc = m_memptr->getDescPtr();
OPENVINO_ASSERT(memdesc->hasLayoutType(LayoutType::ncsp), "intel_cpu::Tensor only supports memory with ncsp layout.");

m_element_type = InferenceEngine::details::convertPrecision(memdesc->getPrecision());
m_element_type = memdesc->getPrecision();
}

void Tensor::set_shape(ov::Shape new_shape) {
Expand Down
56 changes: 28 additions & 28 deletions src/plugins/intel_cpu/src/dnnl_extension_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,63 +42,63 @@ uint8_t DnnlExtensionUtils::sizeOfDataType(dnnl::memory::data_type dataType) {
}
}

memory::data_type DnnlExtensionUtils::IEPrecisionToDataType(const InferenceEngine::Precision& prec) {
switch (prec) {
case InferenceEngine::Precision::FP32:
dnnl::memory::data_type DnnlExtensionUtils::ElementTypeToDataType(const ov::element::Type& elementType) {
switch (elementType) {
case ov::element::f32:
return memory::data_type::f32;
case InferenceEngine::Precision::I32:
case ov::element::i32:
return memory::data_type::s32;
case InferenceEngine::Precision::BF16:
case ov::element::bf16:
return memory::data_type::bf16;
case InferenceEngine::Precision::I8:
case ov::element::i8:
return memory::data_type::s8;
case InferenceEngine::Precision::U8:
case InferenceEngine::Precision::BOOL:
case ov::element::u8:
case ov::element::boolean:
return memory::data_type::u8;
case InferenceEngine::Precision::BIN:
case ov::element::u1:
return memory::data_type::bin;
case InferenceEngine::Precision::FP16:
case ov::element::f16:
return memory::data_type::f16;
case InferenceEngine::Precision::NF4:
case ov::element::nf4:
return memory::data_type::nf4;
case InferenceEngine::Precision::I4:
case ov::element::i4:
return memory::data_type::s4;
case InferenceEngine::Precision::U4:
case ov::element::u4:
return memory::data_type::u4;
case InferenceEngine::Precision::UNSPECIFIED:
case ov::element::undefined:
return memory::data_type::undef;
default: {
OPENVINO_THROW("The plugin does not support ", prec.name());
OPENVINO_THROW("The plugin does not support ", elementType.to_string());
}
}
}

InferenceEngine::Precision DnnlExtensionUtils::DataTypeToIEPrecision(memory::data_type dataType) {
ov::element::Type DnnlExtensionUtils::DataTypeToElementType(const dnnl::memory::data_type& dataType) {
switch (dataType) {
case memory::data_type::f32:
return InferenceEngine::Precision::FP32;
return ov::element::f32;
case memory::data_type::s32:
return InferenceEngine::Precision::I32;
return ov::element::i32;
case memory::data_type::bf16:
return InferenceEngine::Precision::BF16;
return ov::element::bf16;
case memory::data_type::s8:
return InferenceEngine::Precision::I8;
return ov::element::i8;
case memory::data_type::u8:
return InferenceEngine::Precision::U8;
return ov::element::u8;
case memory::data_type::bin:
return InferenceEngine::Precision::BIN;
return ov::element::u1;
case memory::data_type::f16:
return InferenceEngine::Precision::FP16;
return ov::element::f16;
case memory::data_type::f64:
return InferenceEngine::Precision::FP64;
return ov::element::f64;
case memory::data_type::nf4:
return InferenceEngine::Precision::NF4;
return ov::element::nf4;
case memory::data_type::s4:
return InferenceEngine::Precision::I4;
return ov::element::i4;
case memory::data_type::u4:
return InferenceEngine::Precision::U4;
return ov::element::u4;
case memory::data_type::undef:
return InferenceEngine::Precision::UNSPECIFIED;
return ov::element::undefined;
default: {
OPENVINO_THROW("Unsupported data type.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_cpu/src/dnnl_extension_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class DnnlMemoryDesc;
class DnnlExtensionUtils {
public:
static uint8_t sizeOfDataType(dnnl::memory::data_type dataType);
static dnnl::memory::data_type IEPrecisionToDataType(const InferenceEngine::Precision& prec);
static InferenceEngine::Precision DataTypeToIEPrecision(dnnl::memory::data_type dataType);
static dnnl::memory::data_type ElementTypeToDataType(const ov::element::Type& elementType);
static ov::element::Type DataTypeToElementType(const dnnl::memory::data_type& dataType);
static Dim convertToDim(const dnnl::memory::dim &dim);
static dnnl::memory::dim convertToDnnlDim(const Dim &dim);
static VectorDims convertToVectorDims(const dnnl::memory::dims& dims);
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/intel_cpu/src/dnnl_postops_composer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void DnnlPostOpsComposer::updateWeiScales() {
DEBUG_LOG("Set weight scales mask ", "DNNL_ARG: ", DNNL_ARG_WEIGHTS, " mask: ", wei_scale_mask);
attr.set_scales_mask(DNNL_ARG_WEIGHTS, wei_scale_mask);

DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape({wei_scale_values.size()}));
DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape({wei_scale_values.size()}));
auto mem = std::make_shared<Memory>(engine, memoryDesc);
memcpy(mem->getData(), wei_scale_values.data(), wei_scale_values.size() * sizeof(float));
args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = mem;
Expand All @@ -71,7 +71,7 @@ void DnnlPostOpsComposer::updateDestScales() {
DEBUG_LOG("Set dest scale mask ", "DNNL_ARG: ", DNNL_ARG_DST, " mask: ", 0);
attr.set_scales_mask(DNNL_ARG_DST, 0);

DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape({1}));
DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape({1}));
auto mem = std::make_shared<Memory>(engine, memoryDesc);
memcpy(mem->getData(), &dst_scale_val, sizeof(float));
args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_DST] = mem;
Expand All @@ -86,7 +86,7 @@ void DnnlPostOpsComposer::appendBinary(const dnnl::algorithm alg, const std::vec

DEBUG_LOG("Append binary post op with algorithm: ", convert_to_c(alg));

DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape(*pdims));
DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape(*pdims));
ops.append_binary(alg, memoryDesc.getDnnlDesc());

// copy the data as args
Expand Down Expand Up @@ -259,7 +259,7 @@ MemoryPtr DnnlPostOpsComposer::prepackDecompressionParams(const MemoryCPtr& para

if (needTranspose) {
VectorDims dnnlShape = {shape[0], shape[1]};
DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape(dnnlShape));
DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape(dnnlShape));
mem = std::make_shared<Memory>(engine, memoryDesc);
auto memory_buf = static_cast<float*>(mem->getData());

Expand All @@ -271,7 +271,7 @@ MemoryPtr DnnlPostOpsComposer::prepackDecompressionParams(const MemoryCPtr& para
}
} else {
VectorDims dnnlShape = {shape[shape.size() - 1], shape[0]};
DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape(dnnlShape));
DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape(dnnlShape));
mem = std::make_shared<Memory>(engine, memoryDesc);
auto memory_buf = static_cast<float*>(mem->getData());
const size_t elements_count = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<size_t>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace intel_cpu {
class jit_uni_vcvtneps2bf16 : public jit_emitter {
public:
jit_uni_vcvtneps2bf16(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa,
InferenceEngine::Precision exec_prc = InferenceEngine::Precision::BF16) : jit_emitter(host, host_isa, exec_prc) {
ov::element::Type exec_prc = ov::element::bf16) : jit_emitter(host, host_isa, exec_prc) {
if (!dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_bf16))
prepare_table();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace Xbyak;
namespace ov {
namespace intel_cpu {

jit_convert_emitter::jit_convert_emitter(jit_generator *host, cpu_isa_t host_isa, const std::shared_ptr<ov::Node>& node, Precision exec_prc)
jit_convert_emitter::jit_convert_emitter(jit_generator *host, cpu_isa_t host_isa, const std::shared_ptr<ov::Node>& node, ov::element::Type exec_prc)
: jit_emitter(host, host_isa, exec_prc) {
input_type = node->get_input_element_type(0);
output_type = node->get_output_element_type(0);
Expand Down Expand Up @@ -58,7 +58,7 @@ void jit_convert_emitter::float2bfloat(const std::vector<size_t> &in_vec_idxs, c
}

jit_convert_truncation_emitter::jit_convert_truncation_emitter(jit_generator *host, cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& node, Precision exec_prc)
const std::shared_ptr<ov::Node>& node, ov::element::Type exec_prc)
: jit_convert_emitter(host, host_isa, node, exec_prc) {
prepare_table();
}
Expand Down Expand Up @@ -193,7 +193,7 @@ void jit_convert_truncation_emitter::dword2int8(const std::vector<size_t> &in_ve
}

jit_convert_saturation_emitter::jit_convert_saturation_emitter(jit_generator *host, cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& node, Precision exec_prc)
const std::shared_ptr<ov::Node>& node, ov::element::Type exec_prc)
: jit_convert_emitter(host, host_isa, node, exec_prc) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace intel_cpu {
class jit_convert_emitter : public jit_emitter {
public:
jit_convert_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n, InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32);
const std::shared_ptr<ov::Node>& n, ov::element::Type exec_prc = ov::element::f32);

size_t get_inputs_num() const override;

Expand Down Expand Up @@ -47,7 +47,7 @@ class jit_convert_emitter : public jit_emitter {
class jit_convert_truncation_emitter : public jit_convert_emitter {
public:
jit_convert_truncation_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n, InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32);
const std::shared_ptr<ov::Node>& n, ov::element::Type exec_prc = ov::element::f32);

private:
void emit_impl(const std::vector<size_t>& in, const std::vector<size_t>& out) const override;
Expand All @@ -68,7 +68,7 @@ class jit_convert_truncation_emitter : public jit_convert_emitter {
class jit_convert_saturation_emitter : public jit_convert_emitter {
public:
jit_convert_saturation_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n, InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32);
const std::shared_ptr<ov::Node>& n, ov::element::Type exec_prc = ov::element::f32);

private:
void emit_impl(const std::vector<size_t>& in, const std::vector<size_t>& out) const override;
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/intel_cpu/src/emitters/x64/jit_dnnl_emitters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ std::set<std::vector<element::Type>> jit_dnnl_emitter::get_supported_precisions(
return {{element::f32}};
}

jit_dnnl_emitter::jit_dnnl_emitter(jit_generator *host, cpu_isa_t host_isa, const std::shared_ptr<ov::Node>& node, InferenceEngine::Precision exec_prc)
jit_dnnl_emitter::jit_dnnl_emitter(jit_generator *host, cpu_isa_t host_isa, const std::shared_ptr<ov::Node>& node, ov::element::Type exec_prc)
: jit_emitter(host, host_isa, exec_prc) {

kind = dnnl_eltwise_tanh;
Expand All @@ -29,7 +29,7 @@ jit_dnnl_emitter::jit_dnnl_emitter(jit_generator *host, cpu_isa_t host_isa, cons

jit_dnnl_emitter::jit_dnnl_emitter(jit_generator *host, cpu_isa_t host_isa,
dnnl_alg_kind_t algKind, float alpha, float beta,
InferenceEngine::Precision exec_prc)
ov::element::Type exec_prc)
: jit_emitter(host, host_isa, exec_prc), kind(algKind), alpha(alpha), beta(beta) {

set_injector();
Expand Down Expand Up @@ -85,7 +85,7 @@ void jit_dnnl_emitter::emit_data() const {

jit_dnnl_aux_emitter::jit_dnnl_aux_emitter(jit_generator *host, cpu_isa_t host_isa,
dnnl_alg_kind_t algKind, float inpAlpha, float inpBeta,
InferenceEngine::Precision exec_prc)
ov::element::Type exec_prc)
: jit_dnnl_emitter(host, host_isa, algKind, inpAlpha, inpBeta, exec_prc) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/intel_cpu/src/emitters/x64/jit_dnnl_emitters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class jit_dnnl_emitter : public jit_emitter {
protected:
jit_dnnl_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa,
dnnl_alg_kind_t algKind, float inpAlpha, float inpBeta,
InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32);
ov::element::Type exec_prc = ov::element::f32);
jit_dnnl_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, const std::shared_ptr<ov::Node>& n,
InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32);
ov::element::Type exec_prc = ov::element::f32);
void set_injector();

dnnl_alg_kind_t kind {dnnl_alg_kind_undef};
Expand All @@ -46,7 +46,7 @@ class jit_dnnl_aux_emitter : public jit_dnnl_emitter {
public:
jit_dnnl_aux_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa,
dnnl_alg_kind_t algKind, float inpAlpha, float inpBeta,
InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32);
ov::element::Type exec_prc = ov::element::f32);

private:
};
Expand Down
Loading

0 comments on commit 66a8600

Please sign in to comment.