Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5b5d6ec
Deprecate undefined type and use dynamic where possible
praasz Jan 31, 2025
c598fce
Apply code style
praasz Jan 31, 2025
947aeb6
Fix deprecation in element type
praasz Jan 31, 2025
8ce7911
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 3, 2025
ac1a518
Update precision in skipped tests
praasz Feb 3, 2025
50a815a
Update undefined to dynamic in GPU plugin
praasz Feb 3, 2025
9efdca6
Deprecate undefined in C-API
praasz Feb 3, 2025
4acda26
Use undefined as dynamic until removed
praasz Feb 3, 2025
0e722aa
Fix build issues
praasz Feb 3, 2025
a5aa6f1
Restore formatting in LP test files
praasz Feb 3, 2025
5350d22
Minor fixed and enable shared test eltwise, convolution for undefined…
praasz Feb 4, 2025
b8849ed
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 4, 2025
b31c683
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 4, 2025
f0f8e35
Merge undefined with dynamic type
praasz Feb 5, 2025
cd2f2f5
Add missing changes
praasz Feb 5, 2025
dc5edbd
Fix build issues
praasz Feb 5, 2025
15246d7
Fix skipped tests, remove leftovers
praasz Feb 5, 2025
1ea75b7
Update GPU hash test due precision enum changes values
praasz Feb 5, 2025
38cafbc
Update hash in GPU test
praasz Feb 6, 2025
3986dbc
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 6, 2025
f9ad591
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 7, 2025
c1c4f99
Merge branch 'master' into feature/use-element-dynamic-instead-undefined
praasz Feb 10, 2025
070cbbc
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 12, 2025
088ee8c
Merge branch 'master' into feature/use-element-dynamic-instead-undefined
praasz Feb 12, 2025
7ce685c
Add test to read IR with dynamic, undefined type
praasz Feb 13, 2025
cfc5106
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 13, 2025
3e4e302
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 14, 2025
352be14
Restore style in GPU utils
praasz Feb 14, 2025
103b9a5
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 14, 2025
83a8ce9
Merge branch 'master' into feature/use-element-dynamic-instead-undefined
praasz Feb 18, 2025
42fd69e
Fix code style
praasz Feb 18, 2025
bda3ad4
Merge remote-tracking branch 'origin/master' into feature/use-element…
praasz Feb 19, 2025
dc19f05
Minor changes
praasz Feb 19, 2025
b46d0db
Fix code style
praasz Feb 19, 2025
5a9cbe9
Merge branch 'master' into feature/use-element-dynamic-instead-undefined
praasz Feb 20, 2025
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
2 changes: 1 addition & 1 deletion docs/articles_en/assets/snippets/ov_dynamic_shapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ ov_compiled_model_create_infer_request(compiled_model, &infer_request);

//! [ov_dynamic_shapes:set_input_tensor]
ov_output_const_port_t* input_port = NULL;
ov_element_type_e type = UNDEFINED;
ov_element_type_e type = DYNAMIC;
ov_shape_t input_shape_1;
ov_tensor_t* input_tensor_1 = NULL;
ov_tensor_t* output_tensor = NULL;
Expand Down
24 changes: 11 additions & 13 deletions samples/cpp/benchmark_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ int main(int argc, char* argv[]) {
if (result != config.end())
device_config = result->second;
size_t batchSize = FLAGS_b;
ov::element::Type type = ov::element::undefined;
ov::element::Type type = ov::element::dynamic;
std::string topology_name = "";
std::vector<benchmark_app::InputsInfo> app_inputs_info;
std::string output_name;
Expand Down Expand Up @@ -660,14 +660,14 @@ int main(int argc, char* argv[]) {
std::const_pointer_cast<const ov::Model>(model)->outputs());
}

const auto input_precision = FLAGS_ip.empty() ? ov::element::undefined : getPrecision2(FLAGS_ip);
const auto output_precision = FLAGS_op.empty() ? ov::element::undefined : getPrecision2(FLAGS_op);
const auto input_precision = FLAGS_ip.empty() ? ov::element::dynamic : getPrecision2(FLAGS_ip);
const auto output_precision = FLAGS_op.empty() ? ov::element::dynamic : getPrecision2(FLAGS_op);

const auto& inputs = model->inputs();
for (size_t i = 0; i < inputs.size(); i++) {
const auto& item = inputs[i];
auto iop_precision = ov::element::undefined;
auto type_to_set = ov::element::undefined;
auto iop_precision = ov::element::dynamic;
auto type_to_set = ov::element::dynamic;
std::string name;
try {
// Some tensors might have no names, get_any_name will throw exception in that case.
Expand All @@ -676,18 +676,17 @@ int main(int argc, char* argv[]) {
iop_precision = getPrecision2(user_precisions_map.at(item.get_any_name()));
} catch (...) {
}

if (iop_precision != ov::element::undefined) {
if (iop_precision != ov::element::dynamic) {
type_to_set = iop_precision;
} else if (input_precision != ov::element::undefined) {
} else if (input_precision != ov::element::dynamic) {
type_to_set = input_precision;
} else if (!name.empty() && app_inputs_info[0].at(name).is_image()) {
// image input, set U8
type_to_set = ov::element::u8;
}

auto& in = preproc.input(item.get_any_name());
if (type_to_set != ov::element::undefined) {
if (type_to_set != ov::element::dynamic) {
in.tensor().set_element_type(type_to_set);

if (!name.empty()) {
Expand All @@ -707,17 +706,16 @@ int main(int argc, char* argv[]) {
const auto& outs = model->outputs();
for (size_t i = 0; i < outs.size(); i++) {
const auto& item = outs[i];
auto iop_precision = ov::element::undefined;
auto iop_precision = ov::element::dynamic;
try {
// Some tensors might have no names, get_any_name will throw exception in that case.
// -iop option will not work for those tensors.
iop_precision = getPrecision2(user_precisions_map.at(item.get_any_name()));
} catch (...) {
}

if (iop_precision != ov::element::undefined) {
if (iop_precision != ov::element::dynamic) {
preproc.output(i).tensor().set_element_type(iop_precision);
} else if (output_precision != ov::element::undefined) {
} else if (output_precision != ov::element::dynamic) {
preproc.output(i).tensor().set_element_type(output_precision);
}
}
Expand Down
54 changes: 27 additions & 27 deletions src/bindings/c/include/openvino/c/ov_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,33 @@ typedef enum {
* src/core/include/openvino/core/type/element_type.hpp
*/
typedef enum {
UNDEFINED = 0U, //!< Undefined element type
DYNAMIC, //!< Dynamic element type
BOOLEAN, //!< boolean element type
BF16, //!< bf16 element type
F16, //!< f16 element type
F32, //!< f32 element type
F64, //!< f64 element type
I4, //!< i4 element type
I8, //!< i8 element type
I16, //!< i16 element type
I32, //!< i32 element type
I64, //!< i64 element type
U1, //!< binary element type
U2, //!< u2 element type
U3, //!< u3 element type
U4, //!< u4 element type
U6, //!< u6 element type
U8, //!< u8 element type
U16, //!< u16 element type
U32, //!< u32 element type
U64, //!< u64 element type
NF4, //!< nf4 element type
F8E4M3, //!< f8e4m3 element type
F8E5M3, //!< f8e5m2 element type
STRING, //!< string element type
F4E2M1, //!< f4e2m1 element type
F8E8M0, //!< f8e8m0 element type
UNDEFINED = 0U, //!< Undefined element type
DYNAMIC = UNDEFINED, //!< Dynamic element type
BOOLEAN, //!< boolean element type
BF16, //!< bf16 element type
F16, //!< f16 element type
F32, //!< f32 element type
F64, //!< f64 element type
I4, //!< i4 element type
I8, //!< i8 element type
I16, //!< i16 element type
I32, //!< i32 element type
I64, //!< i64 element type
U1, //!< binary element type
U2, //!< u2 element type
U3, //!< u3 element type
U4, //!< u4 element type
U6, //!< u6 element type
U8, //!< u8 element type
U16, //!< u16 element type
U32, //!< u32 element type
U64, //!< u64 element type
NF4, //!< nf4 element type
F8E4M3, //!< f8e4m3 element type
F8E5M3, //!< f8e5m2 element type
STRING, //!< string element type
F4E2M1, //!< f4e2m1 element type
F8E8M0, //!< f8e8m0 element type
} ov_element_type_e;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/c/src/ov_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "common.h"

const std::map<ov_element_type_e, ov::element::Type> element_type_map = {
{ov_element_type_e::UNDEFINED, ov::element::undefined},
{ov_element_type_e::UNDEFINED, ov::element::dynamic},
{ov_element_type_e::DYNAMIC, ov::element::dynamic},
{ov_element_type_e::BOOLEAN, ov::element::boolean},
{ov_element_type_e::BF16, ov::element::bf16},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def tf_type_to_ov_type(tf_type_int):
try:
ret_type = Type(numpy_type)
except:
ret_type = Type.undefined
ret_type = Type.dynamic
return ret_type


Expand Down Expand Up @@ -169,7 +169,7 @@ def get_attribute(self, name):
return OVAny(Type.dynamic)
return OVAny(tf_type_to_ov_type(variable_value.dtype))
else:
return OVAny(Type.undefined)
return OVAny(Type.dynamic)
return OVAny(tf_type_to_ov_type(type_num))

if name == "value":
Expand Down
3 changes: 1 addition & 2 deletions src/bindings/python/src/pyopenvino/core/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,7 @@ ov::Tensor tensor_from_pointer(py::array& array, const ov::Shape& shape, const o
if (type_helpers::get_ov_type(array) == ov::element::string) {
OPENVINO_THROW("SHARED MEMORY MODE FOR THIS TENSOR IS NOT APPLICABLE! String types can be only copied.");
}

auto element_type = (type == ov::element::undefined) ? Common::type_helpers::get_ov_type(array) : type;
auto element_type = (type == ov::element::dynamic) ? Common::type_helpers::get_ov_type(array) : type;

if (array_helpers::is_contiguous(array)) {
return ov::Tensor(element_type, shape, const_cast<void*>(array.data(0)), {});
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/python/src/pyopenvino/core/tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void regclass_Tensor(py::module m) {
}),
py::arg("array"),
py::arg("shape"),
py::arg("type") = ov::element::undefined,
py::arg("type") = ov::element::dynamic,
py::keep_alive<1, 2>(),
R"(
Another Tensor's special constructor.
Expand Down Expand Up @@ -76,7 +76,7 @@ void regclass_Tensor(py::module m) {
}),
py::arg("array"),
py::arg("shape"),
py::arg("type") = ov::element::undefined,
py::arg("type") = ov::element::dynamic,
py::keep_alive<1, 2>(),
R"(
Another Tensor's special constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void regclass_graph_PreProcessSteps(py::module m) {
[](ov::preprocess::PreProcessSteps& self, ov::element::Type type = {}) {
return &self.convert_element_type(type);
},
py::arg_v("type", ov::element::undefined, "openvino.Type.undefined"),
py::arg_v("type", ov::element::dynamic, "openvino.Type.dynamic"),
R"(
Converts input tensor element type to specified type.
Input tensor must have openvino.Type data type.
Expand Down Expand Up @@ -239,7 +239,7 @@ static void regclass_graph_PostProcessSteps(py::module m) {
[](ov::preprocess::PostProcessSteps& self, ov::element::Type type = {}) {
return &self.convert_element_type(type);
},
py::arg_v("type", ov::element::undefined, "openvino.Type.undefined"),
py::arg_v("type", ov::element::dynamic, "openvino.Type.dynamic"),
R"(
Converts tensor element type to specified type.
Tensor must have openvino.Type data type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void regclass_graph_Type(py::module m) {
:rtype: ov.Type
)");

type.attr("undefined") = ov::element::undefined;
type.attr("undefined") = ov::element::dynamic;
type.attr("dynamic") = ov::element::dynamic;
type.attr("boolean") = ov::element::boolean;
type.attr("f16") = ov::element::f16;
Expand Down
20 changes: 6 additions & 14 deletions src/bindings/python/tests/test_runtime/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,17 @@ def test_basic_ovtypes(ovtype,

def test_undefined_ovtype():
ov_type = Type.undefined
assert ov_type.is_static() is True
assert ov_type.is_dynamic() is False
assert ov_type.is_static() is False
assert ov_type.is_dynamic() is True
assert ov_type.is_real() is False
assert ov_type.real is False
assert ov_type.is_integral() is True
assert ov_type.integral is True
assert ov_type.is_signed() is False
assert ov_type.signed is False
assert ov_type.is_quantized() is False
assert ov_type.quantized is False
assert ov_type.get_type_name() == "undefined"
assert ov_type.type_name == "undefined"
assert ov_type.get_size() == 0
assert ov_type.get_type_name() == "dynamic"
assert ov_type.size == 0

# Note: might depend on the system
import sys
assert ov_type.bitwidth == sys.maxsize * 2 + 1
assert ov_type.get_bitwidth() == sys.maxsize * 2 + 1
assert ov_type.get_size() == 0
assert ov_type.bitwidth == 0
assert ov_type.get_bitwidth() == 0


def test_dynamic_ov_type():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace precision_set {

class LP_TRANSFORMATIONS_API DataPrecision {
public:
DataPrecision() : precision(element::undefined), min(0.f), max(0.f), hasZeroPoint(false) {}
DataPrecision() : precision(element::dynamic), min(0.f), max(0.f), hasZeroPoint(false) {}

explicit DataPrecision(const element::Type& precision) {
this->precision = precision;
Expand All @@ -48,10 +48,9 @@ class LP_TRANSFORMATIONS_API DataPrecision {
hasZeroPoint(hasZeroPoint) {}

bool empty() const noexcept {
assert(
((precision == element::undefined) && (min == 0.f) && (max == 0.f) && (!hasZeroPoint)) ||
((precision != element::undefined) && (max != 0.f)));
return (precision == element::undefined) && (min == 0.f) && (max == 0.f) && (!hasZeroPoint);
assert(((precision == element::dynamic) && (min == 0.f) && (max == 0.f) && (!hasZeroPoint)) ||
((precision != element::dynamic) && (max != 0.f)));
return (precision == element::dynamic) && (min == 0.f) && (max == 0.f) && (!hasZeroPoint);
}

static bool isSupported(const element::Type& precision) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ class LP_TRANSFORMATIONS_API NetworkHelper {

static size_t getParentOutputIndex(const std::shared_ptr<ov::Node>& parent, const std::shared_ptr<ov::Node>& child);

static FakeQuantizeDequantizationValues createEmptyValues(
const FakeQuantizeDequantization& dequantization,
const element::Type& precision = element::undefined);
static FakeQuantizeDequantizationValues createEmptyValues(const FakeQuantizeDequantization& dequantization,
const element::Type& precision = element::dynamic);

static bool isZeroConst(const std::shared_ptr<Node>& node);
static bool checkZeroPoint(const std::shared_ptr<Node>& node, const DataPrecision& dataPrecision = DataPrecision());
Expand Down Expand Up @@ -293,8 +292,13 @@ std::shared_ptr<Node> NetworkHelper::setOutDataPrecision(std::shared_ptr<Operati

template <typename T>
std::shared_ptr<Node> make_op_pattern(const ov::NodeVector& args) {
return std::make_shared<ov::pass::pattern::op::Any>(element::undefined, PartialShape{},
[](std::shared_ptr<Node> n) {return !!ov::as_type_ptr<T>(n); }, args);
return std::make_shared<ov::pass::pattern::op::Any>(
element::dynamic,
PartialShape{},
[](std::shared_ptr<Node> n) {
return !!ov::as_type_ptr<T>(n);
},
args);
}

template <typename T, typename... Args>
Expand Down
4 changes: 2 additions & 2 deletions src/common/low_precision_transformations/src/concat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ bool ConcatTransformation::canBeTransformed(const std::shared_ptr<Node>& layer)
if (constant == nullptr) {
return true;
}
if (const_precision == element::undefined) {
if (const_precision == element::dynamic) {
const_precision = constant->get_element_type();
return true;
}
Expand All @@ -320,7 +320,7 @@ bool ConcatTransformation::canBeTransformed(const std::shared_ptr<Node>& layer)
return false;
}

if (precision == element::undefined) {
if (precision == element::dynamic) {
precision = dequantization.data.get_element_type();
} else if (precision != dequantization.data.get_element_type()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ std::shared_ptr<opset1::Constant> getConstant(const std::shared_ptr<Node>& eltwi

bool all_precisions_equal(const std::shared_ptr<Node>& node) {
const auto& inputs = node->inputs();
const auto first_input_precision = inputs.empty() ? element::undefined : inputs[0].get_element_type();
const auto first_input_precision = inputs.empty() ? element::dynamic : inputs[0].get_element_type();
if (!inputs.empty()) {
const auto first_input_precision = inputs[0].get_element_type();
if (std::any_of(
Expand All @@ -109,7 +109,7 @@ bool all_precisions_equal(const std::shared_ptr<Node>& node) {
const auto& outputs = node->outputs();
if (!outputs.empty()) {
const auto first_output_precision = outputs[0].get_element_type();
if ((first_input_precision != element::undefined) && (first_input_precision != first_output_precision)) {
if ((first_input_precision != element::dynamic) && (first_input_precision != first_output_precision)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ bool FakeQuantizeDecompositionTransformation::transform(ov::pass::pattern::Match

const DataPrecision expectedDataPrecision = fq_decomposition::getDataPrecisionByOutputPortAndFakeQuantize(layer);
// TODO: need test to compose FakeQuantize
if ((expectedDataPrecision.precision == element::undefined) || (expectedDataPrecision.precision == outputPrecision)) {
if ((expectedDataPrecision.precision == element::dynamic) ||
(expectedDataPrecision.precision == outputPrecision)) {
return rewritten;
}

Expand Down Expand Up @@ -363,7 +364,7 @@ bool FakeQuantizeDecompositionTransformation::transform(ov::pass::pattern::Match

// if IntervalsAlignment attribute is defined then, the attribute defines decomposition parameters,
// if IntervalsAlignment attribute is not defined, then FakeQuantize operation intervals define decomposition parameters
if (dataPrecision.precision == element::undefined) {
if (dataPrecision.precision == element::dynamic) {
element::Type precision;
const auto levels = layer->get_levels();
const std::vector<float> outputLowValues = ov::as_type_ptr<opset1::Constant>(layer->get_input_node_shared_ptr(3))->cast_vector<float>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ LayerTransformation::PrecisionDetails LayerTransformation::getPrecisionDetails(
unsignedPrecision = !signedPrecision;
}

element::Type resultPrecision = element::undefined;
element::Type resultPrecision = element::dynamic;
// if zero point exists then result precision has to be defined by client code
if (!hasZeroPoint) {
if (signedPrecision && (!unsignedPrecision)) {
Expand Down Expand Up @@ -335,8 +335,7 @@ DataPrecision LayerTransformation::getDataPrecision(
printDequantizationInfo(layer);
#endif
PrecisionDetails precisionDetailsAtOutputIntervals = getPrecisionDetails(quantizationDetails);

if (precisionDetailsAtOutputIntervals.precision != element::undefined) {
if (precisionDetailsAtOutputIntervals.precision != element::dynamic) {
// FakeQuantize optimal precision not deined
if (!requiredPrecisions.empty()) {
const auto foundIt = std::find(requiredPrecisions.begin(), requiredPrecisions.end(), precisionDetailsAtOutputIntervals.precision);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool MultiplyToGroupConvolutionTransformation::transform(ov::pass::pattern::Matc
dequantization = NetworkHelper::foldDequantization(multiply, inputIndex, defaultPrecisions);
}

element::Type weightsPrecision = element::undefined;
element::Type weightsPrecision = element::dynamic;
if (updatePrecisions) {
// try to find restrictions on weights for GroupConvolution
if (restrictions.size() > 1ul) {
Expand All @@ -65,7 +65,7 @@ bool MultiplyToGroupConvolutionTransformation::transform(ov::pass::pattern::Matc
}

// if restrictions are absent precisions attribute is used
if (weightsPrecision == element::undefined) {
if (weightsPrecision == element::dynamic) {
const auto precisionsAttribute = getAttribute<PrecisionsAttribute>(multiply->input(inputIndex == 0ul ? 1ul : 0ul));
const auto precisions = precisionsAttribute == nullptr ?
defaultPrecisions :
Expand Down
Loading
Loading