coremltools
coremltools copied to clipboard
not create new symbol with immutable shape convolution. #1867
🌱
Hi, according to this PR which looked to be merged, when a convolution does not mutate dimension size for a symbolic shape, no new symbol should be created, but this is not what I seed in the code. So should we expect this behavior or not?
Current implementation of conv shape inference
https://github.com/apple/coremltools/blob/7521b68fba363d4add0c772750d119e4d9815ce6/coremltools/converters/mil/mil/ops/defs/_utils.py#L326-L327
This is a minimal example to verify a new symbol is created
w = np.ones((128, 64, 1, 1))
@mb.program(
input_specs=[
mb.TensorSpec(mil.input_types.EnumeratedShapes(shapes=[(1, 64, 1, 128), (1, 64, 1, 256)]).symbolic_shape, dtype=mil.input_types.types.fp32),
],
opset_version=mil.builder.AvailableTarget.iOS17,
)
def conv_shape_debug(x):
return mb.conv(x=x, weight=w)
print(conv_shape_debug)
>>>main[CoreML7](%x: (1, 64, 1, is586, fp32)(Tensor)) {
block165() {
%conv_7: (1, 128, 1, is587, fp32)(Tensor) = conv(x=%x, weight=%conv_7_weight_0, strides=[1, 1], pad_type="valid", pad=[0, 0, 0, 0], dilations=[1, 1], groups=1, name="conv_7")
} -> (%conv_7)
}