MatMulInteger#

MatMulInteger - 10#

Version

  • name: MatMulInteger (GitHub)

  • domain: main

  • since_version: 10

  • function:

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 10.

Summary

Inputs

Between 2 and 4 inputs.

  • A (heterogeneous) - T1:

  • B (heterogeneous) - T2:

  • a_zero_point (optional, heterogeneous) - T1:

  • b_zero_point (optional, heterogeneous) - T2:

Outputs

  • Y (heterogeneous) - T3:

Type Constraints

  • T1 in ( tensor(int8), tensor(uint8) ): Constrain input A data type to 8-bit integer tensor.

  • T2 in ( tensor(int8), tensor(uint8) ): Constrain input B data type to 8-bit integer tensor.

  • T3 in ( tensor(int32) ): Constrain output Y data type as 32-bit integer tensor.

Examples

default

import numpy as np
import onnx

node = onnx.helper.make_node(
    "MatMulInteger",
    inputs=["A", "B", "a_zero_point", "b_zero_point"],
    outputs=["Y"],
)

A = np.array(
    [
        [11, 7, 3],
        [10, 6, 2],
        [9, 5, 1],
        [8, 4, 0],
    ],
    dtype=np.uint8,
)

a_zero_point = np.array([12], dtype=np.uint8)

B = np.array(
    [
        [1, 4],
        [2, 5],
        [3, 6],
    ],
    dtype=np.uint8,
)

b_zero_point = np.array([0], dtype=np.uint8)

output = np.array(
    [
        [-38, -83],
        [-44, -98],
        [-50, -113],
        [-56, -128],
    ],
    dtype=np.int32,
)

expect(
    node,
    inputs=[A, B, a_zero_point, b_zero_point],
    outputs=[output],
    name="test_matmulinteger",
)