Remove NF4 Convert from public API (#20666)

* Remove NF4 Convert from public API

* Fixed build
This commit is contained in:
Ilya Churaev 2023-10-24 19:19:16 +04:00 committed by GitHub
parent 337e225dbd
commit 124f2bc5c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 5 deletions

View File

@ -20,7 +20,6 @@
#include "openvino/core/rtti.hpp"
#include "openvino/core/type/bfloat16.hpp"
#include "openvino/core/type/float16.hpp"
#include "openvino/core/type/nf4.hpp"
/**
* @defgroup ov_element_cpp_api Element types

View File

@ -705,15 +705,15 @@ private:
auto p = get_data_ptr_nc<Type>();
size_t i = 0;
for (; i < source.size() / 2; i++) {
const auto idx1 = ConvertNF4::quantize(static_cast<float>(source[i * 2]));
const auto idx2 = ConvertNF4::quantize(static_cast<float>(source[i * 2 + 1]));
const auto idx1 = quantize_nf4(static_cast<float>(source[i * 2]));
const auto idx2 = quantize_nf4(static_cast<float>(source[i * 2 + 1]));
const auto v1 = value_in_range<Type>(idx1) & 0x0F;
const auto v2 = value_in_range<Type>(idx2) & 0x0F;
const auto v = (v2 << 4) | v1;
p[i] = static_cast<StorageDataType>(v);
}
if (source.size() % 2) {
const auto idx1 = ConvertNF4::quantize(static_cast<float>(source[i * 2]));
const auto idx1 = quantize_nf4(static_cast<float>(source[i * 2]));
const auto v = value_in_range<Type>(idx1) & 0x0F;
p[i] = static_cast<StorageDataType>(v);
}
@ -853,6 +853,7 @@ private:
}
return shape_size(m_shape) * m_element_type.size();
}
static uint8_t quantize_nf4(float x);
element::Type m_element_type;
Shape m_shape{};

View File

@ -8,6 +8,7 @@
#include "openvino/core/type/element_type.hpp"
#include "openvino/core/type/float16.hpp"
#include "openvino/core/type/nf4.hpp"
namespace ov {
namespace reference {
@ -87,7 +88,7 @@ void lp_convert(const TI* arg, TO* out, size_t count, element::Type_t src_type,
} else if (dst_type == element::i4) {
detail::set_i4(output, i, detail::get_value<int8_t, TI>(input, i, src_type));
} else if (src_type == element::nf4) {
ConvertNF4::unpack(out, input, i);
ov::ConvertNF4::unpack(out, input, i);
} else {
out[i] = detail::get_value<TO, TI>(input, i, src_type);
}

View File

@ -13,6 +13,9 @@
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/tensor.hpp"
#include "openvino/core/type/element_type.hpp"
#include "openvino/core/type/float16.hpp"
#include "openvino/core/type/nf4.hpp"
#include "openvino/runtime/shared_buffer.hpp"
template <typename T>
@ -606,3 +609,7 @@ bool ov::op::v0::Constant::evaluate_lower(TensorVector& outputs) const {
bool ov::op::v0::Constant::evaluate_upper(TensorVector& outputs) const {
return evaluate(outputs, {});
}
uint8_t ov::op::v0::Constant::quantize_nf4(float x) {
return ov::ConvertNF4::quantize(x);
}