Skip to content

Commit

Permalink
[CPU] Implement fp8 conversion (#27949)
Browse files Browse the repository at this point in the history
### Details:
 - *Implement fp8 conversion with the following combinations:*
     _fp32<->f8e4m3, fp16<->f8e4m3, bf16<->f8e4m3_
     _fp32<->f8e5m2, fp16<->f8e5m2, bf16<->f8e5m2_

### Tickets:
 - *[CVS-156962](https://jira.devtools.intel.com/browse/CVS-156962)*
  • Loading branch information
xuchen-intel authored Dec 25, 2024
1 parent b25413c commit 35f2a0c
Show file tree
Hide file tree
Showing 11 changed files with 492 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/frontends/onnx/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True):
skip_dynamic_model = pytest.mark.skip(reason="CPU plug-in can't load a model with dynamic output shapes via legacy API")

# ONNX 1.14
xfail_issue_119896 = xfail_test(reason="Unsupported element type: FLOAT8")
xfail_issue_119896 = xfail_test(reason="Unsupported element type: FLOAT8", strict=False)
xfail_issue_119900 = xfail_test(reason="While validating ONNX node '<Node(Resize): Y>': "
"half_pixel_symmetric - this type of coordinate transformation mode "
"is not supported. Choose one of the following modes: "
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/intel_cpu/src/dnnl_extension_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ uint8_t DnnlExtensionUtils::sizeOfDataType(dnnl::memory::data_type dataType) {
case dnnl::memory::data_type::s4:
case dnnl::memory::data_type::u4:
case dnnl::memory::data_type::f8_e8m0:
case dnnl::memory::data_type::f8_e4m3:
case dnnl::memory::data_type::f8_e5m2:
case dnnl::memory::data_type::f4_e2m1:
return 1;
case dnnl::memory::data_type::undef:
Expand Down Expand Up @@ -70,6 +72,10 @@ dnnl::memory::data_type DnnlExtensionUtils::ElementTypeToDataType(const ov::elem
return memory::data_type::u4;
case ov::element::f8e8m0:
return memory::data_type::f8_e8m0;
case ov::element::f8e4m3:
return memory::data_type::f8_e4m3;
case ov::element::f8e5m2:
return memory::data_type::f8_e5m2;
case ov::element::f4e2m1:
return memory::data_type::f4_e2m1;
case ov::element::undefined:
Expand Down Expand Up @@ -106,6 +112,10 @@ ov::element::Type DnnlExtensionUtils::DataTypeToElementType(const dnnl::memory::
return ov::element::u4;
case memory::data_type::f8_e8m0:
return ov::element::f8e8m0;
case memory::data_type::f8_e4m3:
return ov::element::f8e4m3;
case memory::data_type::f8_e5m2:
return ov::element::f8e5m2;
case memory::data_type::f4_e2m1:
return ov::element::f4e2m1;
case memory::data_type::undef:
Expand Down
Loading

0 comments on commit 35f2a0c

Please sign in to comment.