apple / apple/coremltools

not create new symbol with immutable shape convolution. #1867

Open
#2,229 7 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## 🌱
Hi, according to this [PR](https://github.com/apple/coremltools/pull/1867/files) 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

```python
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)
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the convolution shape-inference logic in coremltools/converters/mil/mil/ops/defs/_utils.py at the referenced lines, then compare its behavior with PR #1867. Run the minimal Python example from the issue and determine whether an immutable symbolic dimension should retain its symbol; done means the expected behavior is established and the example no longer produces an unintended new symbol.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.