[ONNX] MatMulInteger (#7825)

This commit is contained in:
Dawid Kożykowski 2021-10-06 13:53:47 +02:00 committed by GitHub
parent 9add27fd74
commit 659daf610f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1331 additions and 16 deletions

View File

@ -0,0 +1,55 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "op/matmul_integer.hpp"
#include <cstddef>
#include <memory>
#include <vector>
#include "default_opset.hpp"
namespace ngraph {
namespace onnx_import {
namespace op {
namespace set_1 {
OutputVector matmul_integer(const Node& node) {
const OutputVector& inputs = node.get_ng_inputs();
const auto& A = inputs.at(0);
const auto& B = inputs.at(1);
const auto& A_zero_point =
(inputs.size() > 2) ? inputs.at(2) : ngraph::op::Constant::create(ngraph::element::i32, {1}, {0});
const auto& B_zero_point =
(inputs.size() > 3) ? inputs.at(3) : ngraph::op::Constant::create(ngraph::element::i32, {1}, {0});
const auto& converted_A = std::make_shared<default_opset::Convert>(A, element::i32);
const auto& converted_B = std::make_shared<default_opset::Convert>(B, element::i32);
const auto& converted_A_zero_point = std::make_shared<default_opset::Convert>(A_zero_point, element::i32);
const auto& converted_B_zero_point = std::make_shared<default_opset::Convert>(B_zero_point, element::i32);
const auto& A_zero_point_rank = A_zero_point.get_partial_shape().rank();
Output<ngraph::Node> shifted_A;
if (A_zero_point_rank.is_static() && A_zero_point_rank.get_length() == 1) {
const auto& one_node = ngraph::op::Constant::create(ngraph::element::i32, {1}, {1});
const auto& reshaped_A_zero_point =
std::make_shared<default_opset::Unsqueeze>(converted_A_zero_point, one_node);
shifted_A = std::make_shared<default_opset::Subtract>(converted_A, reshaped_A_zero_point);
} else {
shifted_A = std::make_shared<default_opset::Subtract>(converted_A, converted_A_zero_point);
}
const auto& shifted_B = std::make_shared<default_opset::Subtract>(converted_B, converted_B_zero_point);
const auto& result = std::make_shared<default_opset::MatMul>(shifted_A, shifted_B);
return {result};
}
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "ngraph/node.hpp"
#include "onnx_import/core/node.hpp"
namespace ngraph {
namespace onnx_import {
namespace op {
namespace set_1 {
/// \brief Performs ONNX MatMulInteger operation.
///
/// \param node The ONNX node object representing this operation.
///
/// \return The vector containing Ngraph nodes producing output of ONNX quantizied
/// matrix multiplication integer operation.
OutputVector matmul_integer(const Node& node);
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph

View File

@ -81,6 +81,7 @@
#include "op/lrn.hpp"
#include "op/lstm.hpp"
#include "op/matmul.hpp"
#include "op/matmul_integer.hpp"
#include "op/max.hpp"
#include "op/max_pool.hpp"
#include "op/mean.hpp"
@ -352,6 +353,7 @@ OperatorsBridge::OperatorsBridge() {
REGISTER_OPERATOR("LpNormalization", 1, lp_norm);
REGISTER_OPERATOR("LRN", 1, lrn);
REGISTER_OPERATOR("LSTM", 1, lstm);
REGISTER_OPERATOR("MatMulInteger", 1, matmul_integer);
REGISTER_OPERATOR("MatMul", 1, matmul);
REGISTER_OPERATOR("MaxPool", 1, max_pool);
REGISTER_OPERATOR("Max", 1, max);

View File

@ -0,0 +1,91 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
input: "b_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 3
}
dim {
dim_value: 2
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
}
}
}
}
input {
name: "b_zero_point"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 4
}
dim {
dim_value: 2
}
}
}
}
}
}
opset_import {
domain: ""
version: 13
}

View File

@ -0,0 +1,83 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,106 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
input: "b_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
}
}
}
}
input {
name: "b_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 1
}
dim {
dim_value: 4
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,97 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
input: "b_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}
input {
name: "b_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,109 @@
ir_version: 5
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
input: "b_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "test"
input {
name: "A"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
}
}
}
}
input {
name: "b_zero_point"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,81 @@
ir_version: 5
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
output: "Y"
op_type: "MatMulInteger"
}
name: "test"
input {
name: "A"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,91 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
input: "b_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}
input {
name: "b_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,127 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
input: "b_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 1
}
}
}
}
}
input {
name: "b_zero_point"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 1
}
dim {
dim_value: 3
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,63 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 5
}
dim {
dim_value: 3
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -0,0 +1,91 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "A"
input: "B"
input: "a_zero_point"
input: "b_zero_point"
output: "Y"
op_type: "MatMulInteger"
}
name: "MatMulInt"
input {
name: "A"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
input {
name: "B"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 5
}
dim {
dim_value: 3
}
}
}
}
}
input {
name: "a_zero_point"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 4
}
}
}
}
}
input {
name: "b_zero_point"
type {
tensor_type {
elem_type: 2
shape {
dim {
dim_value: 3
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 4
}
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
domain: ""
version: 10
}

View File

@ -402,6 +402,316 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_quant_conv_linear_onnx_example) {
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_2d_simple_zero_point) {
auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<uint8_t>{11, 7, 3,
10, 6, 2,
9, 5, 1,
8, 4, 0}); // A
test_case.add_input(std::vector<uint8_t>{1, 4,
2, 5,
3, 6}); // B
test_case.add_input(std::vector<uint8_t>{12}); // a_zero_point
test_case.add_input(std::vector<uint8_t>{0}); // b_zero_point
test_case.add_expected_output({4, 2}, std::vector<int32_t>{-38, -83,
-44, -98,
-50, -113,
-56, -128}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_int8) {
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_int8.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<int8_t>{-3, 7, 5, -6,
4, -5, 8, 7}); // A
test_case.add_input(std::vector<int8_t>{ 5, -3, 7, 8,
-6, -8, -3, 6,
7, 9, 9, -5,
8, 7, -6, 7}); // B
test_case.add_input(std::vector<int8_t>{5}); // a_zero_point
test_case.add_input(std::vector<int8_t>{5}); // b_zero_point
test_case.add_expected_output({2, 4}, std::vector<int32_t>{-55, 16, 89, -44,
122, 154, 68, -39}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_vectorized_zero_point) {
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_vectorized_zero_point.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<uint8_t>{11, 22, 33, 44, 55,
22, 33, 44, 55, 66,
33, 44, 55, 66, 77,
44, 55, 66, 77, 88}); // A
test_case.add_input(std::vector<uint8_t>{ 13, 1, 3,
21, 49, 31,
9, 0, 2,
107, 7, 94,
1, 63, 127}); // B
test_case.add_input(std::vector<uint8_t>{33, 44, 55, 66}); // a_zero_point
test_case.add_input(std::vector<uint8_t>{10, 20, 30}); // b_zero_point
test_case.add_expected_output({4, 3}, std::vector<int32_t>{682, 902, 3421,
682, 902, 3421,
682, 902, 3421,
682, 902, 3421}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_no_zero_point) {
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_no_zero_point.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<uint8_t>{11, 22, 33, 44, 55,
22, 33, 44, 55, 66,
33, 44, 55, 66, 77,
44, 55, 66, 77, 88}); // A
test_case.add_input(std::vector<uint8_t>{ 13, 1, 3,
21, 49, 31,
9, 0, 2,
107, 7, 94,
1, 63, 127}); // B
test_case.add_expected_output({4, 3}, std::vector<int32_t>{ 5665, 4862, 11902,
7326, 6182, 14729,
8987, 7502, 17556,
10648, 8822, 20383}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_2d_x_3d) {
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_2d_x_3d.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<int8_t>{7, -3, 1, 2,
0, 2, -4, 6}); // A
test_case.add_input(std::vector<int8_t>{1, -13, 10,
2, -16, 14,
3, -19, 18,
4, -22, 22,
-1, 13, -10,
-2, 16, -14,
-3, 19, -18,
-4, 22, -22}); // B
test_case.add_input(std::vector<int8_t>{-4}); // a_zero_point
test_case.add_expected_output({2, 2, 3}, std::vector<int32_t>{52, -386, 346,
56, -368, 344,
-52, 386, -346,
-56, 368, -344}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_3d_x_2d) {
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_3d_x_2d.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<int8_t>{-13, 11, -1, -2,
4, -2, 3, 10,
8, -2, 4, 5,
-4, -3, 1, 2}); // A
test_case.add_input(std::vector<int8_t>{ 1, -3, 5,
7, -2, -10,
-13, 9, 7,
11, 3, -3}); // B
test_case.add_input(std::vector<int8_t>{4}); // a_zero_point
test_case.add_input(std::vector<int8_t>{-3}); // a_zero_point
test_case.add_expected_output({2, 2, 3}, std::vector<int32_t>{-32, -89, -235,
34, 18, 32,
-30, 0, 74,
-100, -55, -45}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_3d) {
auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_3d.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<uint8_t>{125, 135, 145, 155,
130, 140, 150, 160,
125, 135, 145, 155,
130, 140, 150, 160}); // A
test_case.add_input(std::vector<int8_t>{-10, -5, 0, 5,
-5, 0, 5, 10,
-5, -4, -3, -2,
-1, 0, 1, 2,
10, 5, 0, -5,
5, 0, -5, -10,
5, 4, 3, 2,
1, 0, -1, -2}); // B
test_case.add_input(std::vector<uint8_t>{150}); // a_zero_point
test_case.add_input(std::vector<int8_t>{5, 10, 15, 20,
-5, -10, -15, -20}); // b_zero_point
test_case.add_expected_output({2, 2, 4}, std::vector<int32_t>{545, 545, 545, 545,
340, 300, 260, 220,
-545, -545, -545, -545,
-340, -300, -260, -220}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_4d) {
auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_4d.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<uint8_t>{0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23}); // A
test_case.add_input(std::vector<uint8_t>{0, 1, 2,
3, 4, 5,
6, 7, 8,
9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23}); // B
test_case.add_input(std::vector<uint8_t>{0}); // a_zero_point
test_case.add_input(std::vector<uint8_t>{0}); // b_zero_point
test_case.add_expected_output<int32_t>({1, 2, 3, 3}, std::vector<int32_t> {42, 48, 54,
114, 136, 158,
186, 224, 262,
906, 960, 1014,
1170, 1240, 1310,
1434, 1520, 1606}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_4d_zero_point) {
auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_4d.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<uint8_t>{0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15,
16, 17, 18, 19,
20, 21, 22, 23}); // A
test_case.add_input(std::vector<uint8_t>{0, 1, 2,
3, 4, 5,
6, 7, 8,
9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23}); // B
test_case.add_input(std::vector<uint8_t>{1}); // a_zero_point
test_case.add_input(std::vector<uint8_t>{1}); // b_zero_point
test_case.add_expected_output<int32_t>({1, 2, 3, 3}, std::vector<int32_t>{22, 24, 26,
78, 96, 114,
134, 168, 202,
790, 840, 890,
1038, 1104, 1170,
1286, 1368, 1450}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_integer_matrix_zero_point) {
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_integer_matrix_zero_point.onnx"));
auto test_case = test::TestCase<TestEngine>(function);
// don't change style for better readibility
// clang-format off
test_case.add_input(std::vector<uint8_t>{0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15}); // A
test_case.add_input(std::vector<uint8_t>{0, 1, 2,
3, 4, 5,
6, 7, 8,
9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23}); // B
test_case.add_input(std::vector<uint8_t>{1,
2,
3,
4}); // a_zero_point
test_case.add_input(std::vector<uint8_t>{1, 2, 3,
4, 5, 6}); // b_zero_point
test_case.add_expected_output<int32_t>({1, 2, 2, 3}, std::vector<int32_t>{22, 22, 22,
64, 64, 64,
340, 340, 340,
490, 490, 490}); // Y
// clang-format on
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_qlinear_matmul_3d) {
auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/qlinear_matmul_3d.onnx"));

View File

@ -31,13 +31,6 @@ onnx_model_conv_integer_no_zero_point
onnx_model_conv_integer_pads
# Unsupported operator detected in the graph: QuantizedDot
onnx_model_matmul_integer
onnx_model_matmul_integer_zero_point_zero
onnx_model_matmul_integer_no_zero_point
onnx_model_matmul_integer_scalar
onnx_model_matmul_integer_4d
onnx_model_matmul_integer_4d_zero_point
onnx_model_matmul_integer_4d_no_zero_point
onnx_model_qlinear_matmul
onnx_model_qlinear_matmul_3d

View File

@ -14,13 +14,6 @@ INTERPRETER.onnx_resize11_sizes_nearest_asymmetric_floor
# nGraph does not support the following ONNX operations
INTERPRETER.onnx_model_qlinear_matmul
INTERPRETER.onnx_model_qlinear_matmul_3d
INTERPRETER.onnx_model_matmul_integer
INTERPRETER.onnx_model_matmul_integer_zero_point_zero
INTERPRETER.onnx_model_matmul_integer_no_zero_point
INTERPRETER.onnx_model_matmul_integer_scalar
INTERPRETER.onnx_model_matmul_integer_4d
INTERPRETER.onnx_model_matmul_integer_4d_zero_point
INTERPRETER.onnx_model_matmul_integer_4d_no_zero_point
# Disabled tests for disabled reference implementations
INTERPRETER.onnx_dyn_shapes_expand_uint16_dyn_shape
@ -139,4 +132,4 @@ INTERPRETER.zero_sized_negative
# No support yet for RandomUniform
INTERPRETER.onnx_model_random_uniform
INTERPRETER.onnx_model_random_uniform_like
INTERPRETER.onnx_model_random_uniform_like

View File

@ -333,7 +333,6 @@ tests_expected_to_fail = [
),
(
xfail_issue_38722,
"OnnxBackendNodeModelTest.test_matmulinteger_cpu",
"OnnxBackendNodeModelTest.test_qlinearmatmul_2D_cpu",
"OnnxBackendNodeModelTest.test_qlinearmatmul_3D_cpu",
),