com.microsoft - QLinearConv#

QLinearConv - 1#

Version

  • name: QLinearConv (GitHub)

  • domain: com.microsoft

  • since_version: 1

  • function:

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 1 of domain com.microsoft.

Summary

Attributes

  • auto_pad - STRING :

  • channels_last - INT :

  • dilations - INTS :

  • group - INT :

  • kernel_shape - INTS :

  • pads - INTS :

  • strides - INTS :

Inputs

Between 8 and 9 inputs.

  • x (heterogeneous) - T1:

  • x_scale (heterogeneous) - tensor(float):

  • x_zero_point (heterogeneous) - T1:

  • w (heterogeneous) - T2:

  • w_scale (heterogeneous) - tensor(float):

  • w_zero_point (heterogeneous) - T2:

  • y_scale (heterogeneous) - tensor(float):

  • y_zero_point (heterogeneous) - T3:

  • B (optional, heterogeneous) - T4:

Outputs

  • y (heterogeneous) - T3:

Type Constraints

  • T1 in ( tensor(int8), tensor(uint8) ):

  • T2 in ( tensor(int8), tensor(uint8) ):

  • T3 in ( tensor(int8), tensor(uint8) ):

  • T4 in ( tensor(int32) ):

Examples

default

import numpy as np
import onnx

node = onnx.helper.make_node(
    "QLinearConv",
    inputs=[
        "x",
        "x_scale",
        "x_zero_point",
        "w",
        "w_scale",
        "w_zero_point",
        "y_scale",
        "y_zero_point",
    ],
    outputs=["y"],
)

x = np.array(
    [
        [255, 174, 162, 25, 203, 168, 58],
        [15, 59, 237, 95, 129, 0, 64],
        [56, 242, 153, 221, 168, 12, 166],
        [232, 178, 186, 195, 237, 162, 237],
        [188, 39, 124, 77, 80, 102, 43],
        [127, 230, 21, 83, 41, 40, 134],
        [255, 154, 92, 141, 42, 148, 247],
    ],
    dtype=np.uint8,
).reshape((1, 1, 7, 7))

x_scale = np.float32(0.00369204697)
x_zero_point = np.uint8(132)

w = np.array([0], dtype=np.uint8).reshape((1, 1, 1, 1))

w_scale = np.array([0.00172794575], dtype=np.float32)
w_zero_point = np.array([255], dtype=np.uint8)

y_scale = np.float32(0.00162681262)
y_zero_point = np.uint8(123)

output = np.array(
    [
        [0, 81, 93, 230, 52, 87, 197],
        [240, 196, 18, 160, 126, 255, 191],
        [199, 13, 102, 34, 87, 243, 89],
        [23, 77, 69, 60, 18, 93, 18],
        [67, 216, 131, 178, 175, 153, 212],
        [128, 25, 234, 172, 214, 215, 121],
        [0, 101, 163, 114, 213, 107, 8],
    ],
    dtype=np.uint8,
).reshape((1, 1, 7, 7))

expect(
    node,
    inputs=[
        x,
        x_scale,
        x_zero_point,
        w,
        w_scale,
        w_zero_point,
        y_scale,
        y_zero_point,
    ],
    outputs=[output],
    name="test_qlinearconv",
)