// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "matmul_integer16.h" #include "core/providers/cpu/math/matmul_helper.h" namespace onnxruntime { namespace contrib { ONNX_OPERATOR_KERNEL_EX( MatMulInteger16, kMSDomain, 1, kCpuExecutionProvider, KernelDefBuilder() .TypeConstraint("T1", DataTypeImpl::GetTensorType()) .TypeConstraint("T2", DataTypeImpl::GetTensorType()) .TypeConstraint("T3", DataTypeImpl::GetTensorType()), MatMulInteger16); template <> Status MatMulInteger16::Compute(OpKernelContext* ctx) const { auto A = ctx->Input(0); auto B = ctx->Input(1); ORT_ENFORCE(A != nullptr && B != nullptr); MatMulComputeHelper helper; ORT_RETURN_IF_ERROR(helper.Compute(A->Shape(), B->Shape())); Tensor* Y = ctx->Output(0, helper.OutputShape()); // Bail out early if the output is going to be empty if (Y->Shape().Size() == 0) return Status::OK(); for (int i = 0; i < static_cast(helper.OutputOffsets().size()); i++) { EigenCastGEMM( A->Data() + helper.LeftOffsets()[i], B->Data() + helper.RightOffsets()[i], Y->MutableData() + helper.OutputOffsets()[i], static_cast(helper.M()), static_cast(helper.N()), static_cast(helper.K())); } return Status::OK(); } } // namespace contrib } // namespace onnxruntime