Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 40 additions & 20 deletions onnxruntime/core/providers/openvino/ov_versions/data_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,23 @@ namespace openvino_ep {

// Ops which are supported only in models(as intermediate nodes) and not in unit tests
std::set<std::string> ops_supported_only_in_model = {
"Add",
"Cast",
"Celu",
"Concat",
"ConstantOfShape",
"DequantizeLinear",
"Dropout",
"Einsum",
"Exp",
"Expand",
"EyeLike",
"GatherElements",
"GatherND",
"GridSample",
"Identity",
"LayerNormalization",
"Loop",
"LSTM",
"NonMaxSuppression",
"NonZero",
"Not",
"OneHot",
"Pad",
"QuantizeLinear",
"RandomNormalLike",
"Range",
"ReduceMin",
"Resize",
"Round",
"Shape",
"Slice",
"Split",
"Tile",
"TopK",
"Trilu"};
"TopK"
};

// Ops which are supported as functions (as composite ops)
std::set<std::string> ops_supported_as_function = {
Expand Down Expand Up @@ -269,6 +251,8 @@ void DataOps::populate_types_supported() {
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_FLOAT));
supported_types_initializer_.insert(
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT32));
supported_types_initializer_.insert(
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT32));
supported_types_initializer_.insert(
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT64));
supported_types_initializer_.insert(
Expand Down Expand Up @@ -317,6 +301,8 @@ void DataOps::populate_types_supported() {
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_BOOL));
supported_types_cpu_.insert(
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_FLOAT));
supported_types_cpu_.insert(
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT32));
supported_types_cpu_.insert(
std::make_pair(V_2020_4, ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT32));
supported_types_cpu_.insert(
Expand Down Expand Up @@ -367,6 +353,7 @@ void DataOps::populate_op_mode_supported() {
no_dimension_supported_.push_back({"DynamicQuantizeLinear", V_2025_2, {"All"}});
no_dimension_supported_.push_back({"Equal", V_2022_1, {"CPU"}});
no_dimension_supported_.push_back({"Equal", V_2023_0, {"GPU"}});
no_dimension_supported_.push_back({"Exp", V_2020_4, {"CPU", "GPU"}});
no_dimension_supported_.push_back({"Expand", V_2023_3, {"CPU"}});
no_dimension_supported_.push_back({"Expand", V_2024_3, {"CPU", "GPU"}});
no_dimension_supported_.push_back({"Floor", V_2020_4, {"All"}});
Expand All @@ -382,6 +369,7 @@ void DataOps::populate_op_mode_supported() {
no_dimension_supported_.push_back({"Mul", V_2020_4, {"All"}});
no_dimension_supported_.push_back({"Neg", V_2023_0, {"CPU", "GPU"}});
no_dimension_supported_.push_back({"Pow", V_2023_0, {"CPU", "GPU"}});
no_dimension_supported_.push_back({"PRelu", V_2020_4, {"CPU", "GPU"}});
no_dimension_supported_.push_back({"QuantizeLinear", V_2021_4, {"All"}});
no_dimension_supported_.push_back({"Range", V_2021_2, {"All"}});
no_dimension_supported_.push_back({"ReduceMax", V_2021_4, {"All"}});
Expand Down Expand Up @@ -489,6 +477,38 @@ void DataOps::populate_op_mode_supported() {
}};
op_list_.insert({"Upsample", obj});
}
{
UnsupportedOpMode obj = {{V_2023_1, V_2023_2, V_2023_3, V_2024_0, V_2024_1, V_2024_2,
V_2024_3, V_2024_4, V_2024_5, V_2024_6, V_2025_0, V_2025_1, V_2025_2, V_2025_3, V_2025_4},
[this](const Node* node, const InitializedTensorSet&) {
auto& attributes = node->GetAttributes();
if (attributes.count("coordinate_transformation_mode") > 0) {
auto coordinate_transformation_mode =
attributes.at("coordinate_transformation_mode").s();
if (coordinate_transformation_mode == "tf_crop_and_resize" ||
coordinate_transformation_mode == "half_pixel_symmetric") {
return true;
}
}
if (attributes.count("antialias") > 0) {
auto antialias_mode =
attributes.at("antialias").i();
auto resize_mode = attributes.at("mode").s();
if (antialias_mode == 1 &&
(resize_mode == "linear" ||
resize_mode == "cubic")) {
return true;
}
}
if (attributes.count("exclude_outside") > 0) {
if (attributes.at("exclude_outside").i() == 1) {
return true;
}
}
return false;
}};
op_list_.insert({"Resize", obj});
}
}

bool DataOps::op_is_supported(std::string name, std::vector<SupportedOp>& op_list) {
Expand Down
74 changes: 71 additions & 3 deletions onnxruntime/test/contrib_ops/quantize_ops_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,46 @@ TEST(QuantizeLinearContribOpTest, QuantizeLinear_per_tensor_float_int8) {
127, -127,
127, -128,
127, -128});
std::unordered_set<std::string> excluded_providers;
// Disable Tensorrt EP due to error: node1_quantize_scale_node: out of bounds channel axis 1. Number of input dimensions is 1.
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
excluded_providers.insert(kTensorrtExecutionProvider);
// Disable OV EP due to different formulation for QuantizeLinear
excluded_providers.insert(kOpenVINOExecutionProvider);
test.ConfigExcludeEps(excluded_providers)
.RunWithConfig();
}

#ifdef USE_OPENVINO
TEST(QuantizeLinearContribOpTest, OVEPQuantizeLinear_per_tensor_float_int8) {
OpTester test("QuantizeLinear", 1, onnxruntime::kMSDomain);
std::vector<int64_t> dims{16};
test.AddInput<float>("x", dims, {
0.f, 2.f, //
3.f, -3.f, // rounding half to even
2.9f, -2.9f, // low case
3.1f, -3.1f, // up case
254.f, -256.f, // critical point
255.f, -257.f, // critical point
256.f, -258.f, // critical point
1000.f, -1000.f // saturate case
});
test.AddInput<float>("y_scale", {}, {2.0f});
test.AddInput<int8_t>("y_zero_point", {}, {1});
test.AddOutput<int8_t>("y", dims,
{1, 2,
2, 0,
2, 0,
3, -1,
127, -127,
127, -128,
127, -128,
127, -128});
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
execution_providers.emplace_back(DefaultOpenVINOExecutionProvider());
test.ConfigEps(std::move(execution_providers))
.RunWithConfig();
}
#endif // USE_OPENVINO

// Test uint16 com.microsoft.QuantizeLinear (per tensor)
TEST(QuantizeLinearContribOpTest, QuantizeLinear_per_tensor_float_uint16) {
Expand All @@ -311,10 +348,41 @@ TEST(QuantizeLinearContribOpTest, QuantizeLinear_per_tensor_float_uint16) {
32769, 32765,
65535, 0,
65535, 0});

std::unordered_set<std::string> excluded_providers;
// Disable Tensorrt EP due to error: unsupported data type
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
excluded_providers.insert(kTensorrtExecutionProvider);
// Disable OV EP due to different formulation for QuantizeLinear
excluded_providers.insert(kOpenVINOExecutionProvider);
test.ConfigExcludeEps(excluded_providers)
.RunWithConfig();
}

#ifdef USE_OPENVINO
TEST(QuantizeLinearContribOpTest, OVEPQuantizeLinear_per_tensor_float_uint16) {
OpTester test("QuantizeLinear", 1, onnxruntime::kMSDomain);
std::vector<int64_t> dims{12};
test.AddInput<float>("x", dims, {
0.f, -128.f, 3.f, -3.f, // rounding half to even
2.9f, -2.9f, // round < .5
3.1f, -3.1f, // round > .5
65536.f, -65534.f, // critical point
70000.f, -70000.f // saturate case
});
test.AddInput<float>("scale", {}, {2.0f}, true);
test.AddInput<uint16_t>("zero_point", {}, {32767}, true);
test.AddOutput<uint16_t>("y", dims,
{32767, 32703,
32768, 32766,
32768, 32766,
32769, 32765,
65535, 0,
65535, 0});
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
execution_providers.emplace_back(DefaultOpenVINOExecutionProvider());
test.ConfigEps(std::move(execution_providers))
.RunWithConfig();
}
#endif // USE_OPENVINO

// Test int16 com.microsoft.QuantizeLinear (per tensor)
TEST(QuantizeLinearContribOpTest, QuantizeLinear_per_tensor_float_int16) {
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/test/providers/cpu/controlflow/loop_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ TEST(Loop, IterationCountAsOutput) {
test.AddOutput<int64_t>("loop_var_0_final", {3, 1}, {0, 1, 2});

// Disable TensorRT on unsupported data type BOOL
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider, kOpenVINOExecutionProvider});
}

#if defined(USE_CUDA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ TEST(ConvTransposeTest, ConvTranspose_InvalidKernelShape) {
// so drop the part that differs from the expected string
"kernel_shape num_dims is not compatible with W num_dims. kernel_shape: {1,1,1,5} W: {1,1,",
{kTensorrtExecutionProvider, kQnnExecutionProvider,
kDmlExecutionProvider}); // TODO: Unskip when fixed #41968513
kDmlExecutionProvider, kOpenVINOExecutionProvider}); // TODO: Unskip when fixed #41968513
}

TEST(ConvTransposeTest, ConvTranspose_onnx) {
Expand Down
5 changes: 5 additions & 0 deletions onnxruntime/test/providers/cpu/tensor/cast_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ void TestCastOp(gsl::span<const SrcType> input,
excluded_provider_types.insert(kCudaExecutionProvider);
}

if (input.size() == 0) {
// The OpenVINO doesn't support 0 size input
excluded_provider_types.insert(kOpenVINOExecutionProvider);
}

if (cuda_only && (excluded_provider_types.count(kCudaExecutionProvider) > 0)) {
return;
}
Expand Down
Loading
Loading