ConvInteger#
ConvInteger - 10#
Version
name: ConvInteger (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
Attributes
auto_pad - STRING : auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER.
dilations - INTS : dilation value along each spatial axis of the filter. If not present, the dilation defaults to 1 along each axis.
group - INT : number of groups input channels and output channels are divided into. default is 1.
kernel_shape - INTS : The shape of the convolution kernel. If not present, should be inferred from input ‘w’.
pads - INTS : Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0.The value represent the number of pixels added to the beginning and end part of the corresponding axis.`pads` format should be as follow [x1_begin, x2_begin…x1_end, x2_end,…], where xi_begin the number ofpixels added at the beginning of axis i and xi_end, the number of pixels added at the end of axis i.This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaultsto 0 along start and end of each spatial axis.
strides - INTS : Stride along each spatial axis. If not present, the stride defaults to 1 along each axis.
Inputs
Between 2 and 4 inputs.
x (heterogeneous) - T1:
w (heterogeneous) - T2:
x_zero_point (optional, heterogeneous) - T1:
w_zero_point (optional, heterogeneous) - T2:
Outputs
y (heterogeneous) - T3:
Type Constraints
T1 in ( tensor(int8), tensor(uint8) ): Constrain input x and its zero point data type to 8-bit integer tensor.
T2 in ( tensor(int8), tensor(uint8) ): Constrain input w and its zero point data type to 8-bit integer tensor.
T3 in ( tensor(int32) ): Constrain output y data type to 32-bit integer tensor.
Examples
_without_padding
import numpy as np
import onnx
x = (
np.array([2, 3, 4, 5, 6, 7, 8, 9, 10])
.astype(np.uint8)
.reshape((1, 1, 3, 3))
)
x_zero_point = np.uint8(1)
w = np.array([1, 1, 1, 1]).astype(np.uint8).reshape((1, 1, 2, 2))
y = np.array([12, 16, 24, 28]).astype(np.int32).reshape(1, 1, 2, 2)
# ConvInteger without padding
convinteger_node = onnx.helper.make_node(
"ConvInteger", inputs=["x", "w", "x_zero_point"], outputs=["y"]
)
expect(
convinteger_node,
inputs=[x, w, x_zero_point],
outputs=[y],
name="test_convinteger_without_padding",
)
_with_padding
import numpy as np
import onnx
x = (
np.array([2, 3, 4, 5, 6, 7, 8, 9, 10])
.astype(np.uint8)
.reshape((1, 1, 3, 3))
)
x_zero_point = np.uint8(1)
w = np.array([1, 1, 1, 1]).astype(np.uint8).reshape((1, 1, 2, 2))
y = (
np.array([1, 3, 5, 3, 5, 12, 16, 9, 11, 24, 28, 15, 7, 15, 17, 9])
.astype(np.int32)
.reshape((1, 1, 4, 4))
)
# ConvInteger with padding
convinteger_node_with_padding = onnx.helper.make_node(
"ConvInteger",
inputs=["x", "w", "x_zero_point"],
outputs=["y"],
pads=[1, 1, 1, 1],
)
expect(
convinteger_node_with_padding,
inputs=[x, w, x_zero_point],
outputs=[y],
name="test_convinteger_with_padding",
)