Skip to content

Commit

Permalink
test qlinear sigmoid
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsalashanubhag committed Jan 7, 2025
1 parent 5ac27a9 commit 1c45690
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
producer_version: ""
model_version: 0
graph {
name: "test_qlinear_leakyrelu"

node {
input: "X"
input: "X_scale"
input: "X_zero_point"
input: "Y_scale"
input: "Y_zero_point"
output: "Y"
op_type: "QLinearLeakyRelu"
attribute {
name: "alpha"
f: 0.1
type: FLOAT
}
domain: "com.microsoft"
}

input {
name: "X"
type {
tensor_type {
elem_type: 3
shape {
dim { dim_value: 2 }
dim { dim_value: 3 }
}
}
}
}

input {
name: "X_scale"
type {
tensor_type {
elem_type: 1 # float
shape {
dim { dim_value: 1 }
}
}
}
}

input {
name: "X_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim { dim_value: 1 }
}
}
}
}

input {
name: "Y_scale"
type {
tensor_type {
elem_type: 1
shape {
dim { dim_value: 1 }
}
}
}
}

input {
name: "Y_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim { dim_value: 1 }
}
}
}
}

output {
name: "Y"
type {
tensor_type {
elem_type: 3
shape {
dim { dim_value: 2 }
dim { dim_value: 3 }
}
}
}
}
}

opset_import {
version: 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
producer_version: ""
model_version: 0
graph {
name: "test_qlinear_sigmoid"

node {
input: "X"
input: "X_scale"
input: "X_zero_point"
input: "Y_scale"
input: "Y_zero_point"
output: "Y"
op_type: "QLinearSigmoid"
domain: "com.microsoft"
}

input {
name: "X"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 3
}
}
}
}
}

input {
name: "X_scale"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
}
}
}
}

input {
name: "X_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}

input {
name: "Y_scale"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
}
}
}
}

input {
name: "Y_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}

output {
name: "Y"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 3
}
}
}
}
}
}

opset_import {
version: 1
}
47 changes: 47 additions & 0 deletions src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,3 +1488,50 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_matmul_integer_to_float) {

test_case.run();
}

OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_qlinearsigmoid) {
const auto model = convert_model("com.microsoft/q_linear_sigmoid.onnx");
auto test_case = ov::test::TestCase(model, s_device);

const std::vector<int8_t> data_X{-50, -25, 0, 25, 50, 75};

const std::vector<float> x_scale{0.1f};
const std::vector<int8_t> x_zero_point{0};
const std::vector<float> y_scale{0.2f};
const std::vector<int8_t> y_zero_point{0};

const std::vector<int8_t> expected_output{0, 0, 2, 4, 4, 4};

test_case.add_input<int8_t>(Shape{2, 3}, data_X);
test_case.add_input<float>(Shape{1}, x_scale);
test_case.add_input<int8_t>(Shape{1}, x_zero_point);
test_case.add_input<float>(Shape{1}, y_scale);
test_case.add_input<int8_t>(Shape{1}, y_zero_point);
test_case.add_expected_output<int8_t>(Shape{2, 3}, expected_output);

test_case.run();
}

OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_qlinearleakyrelu) {
const auto model = convert_model("com.microsoft/q_linear_leaky_relu.onnx");
auto test_case = ov::test::TestCase(model, s_device);

const std::vector<int8_t> data_X{-50, -25, 0, 25, 50, 75};

const std::vector<float> x_scale{0.1f};
const std::vector<int8_t> x_zero_point{0};
const std::vector<float> y_scale{0.2f};
const std::vector<int8_t> y_zero_point{0};

const std::vector<int8_t> expected_output{-2, -1, 0, 12, 25, 37};

test_case.add_input<int8_t>(Shape{2, 3}, data_X);
test_case.add_input<float>(Shape{1}, x_scale);
test_case.add_input<int8_t>(Shape{1}, x_zero_point);
test_case.add_input<float>(Shape{1}, y_scale);
test_case.add_input<int8_t>(Shape{1}, y_zero_point);

test_case.add_expected_output<int8_t>(Shape{2, 3}, expected_output);

test_case.run();
}

0 comments on commit 1c45690

Please sign in to comment.