From ed155ad46a48c2bc703d1073548ef6aea9be8ab2 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous <107195283+TedThemistokleous@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:19:20 -0400 Subject: [PATCH] [MIGraphX EP] Ensure we support all inputs for MatMulInteger and ConvInteger. (#21680) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … to int8 for now Allow for models with biases/full input and only check for int8 support in EP ### Description Allows for all inputs for MatMulInteger and ConvInteger to be supported for prequantized models ### Motivation and Context Fixes issues when using prequantized models that contain weight biases --------- Co-authored-by: Ted Themistokleous --- .../migraphx/migraphx_execution_provider.cc | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc index 4f7643d923..be9f1bd681 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc +++ b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc @@ -316,22 +316,14 @@ static bool IsUnsupportedOpMode(const onnxruntime::GraphViewer& graph_viewer, co return true; } } else if (optype == "ConvInteger") { - if (node->InputDefs()[0]->Shape()->dim_size() != 4) { - return true; - } - - // migraphx can handle only two inputs - if (node->InputDefs().size() != 2) { - return true; - } - - // only support int8 type + // only support int8 and uint8 type const auto& input_type = node->InputDefs()[0]->TypeAsProto(); if (input_type == nullptr) { return true; } - if (input_type->tensor_type().elem_type() != ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT8) { + if ((input_type->tensor_type().elem_type() != ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT8) and + (input_type->tensor_type().elem_type() != ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT8)) { return true; } } else if (optype == "Expand") { @@ -373,18 +365,14 @@ static bool IsUnsupportedOpMode(const onnxruntime::GraphViewer& graph_viewer, co return true; } } else if (optype == "MatMulInteger") { - // migraphx can handle only two inputs - if (node->InputDefs().size() != 2) { - return true; - } - - // only support int8 type + // only support int8 and uint8 type const auto& input_type = node->InputDefs()[0]->TypeAsProto(); if (input_type == nullptr) { return true; } - if (input_type->tensor_type().elem_type() != ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT8) { + if ((input_type->tensor_type().elem_type() != ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT8) and + (input_type->tensor_type().elem_type() != ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT8)) { return true; } } else if (optype == "NonZero") { @@ -456,7 +444,6 @@ static bool IsUnsupportedOpMode(const onnxruntime::GraphViewer& graph_viewer, co return true; } } - } else if (optype == "ReduceSum") { const auto& args = node->InputDefs(); if (args.size() == 2) {