apple / apple/coremltools

Convert Flexible Input shapes problem. ValueError: @max_pool does not support symbolic input spatial shape when ceil_mode is True? What is it mean?

Open
#1,101 6 comments 0 reactions 0 assignees View on GitHub
awaiting response Flexible Shape question
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

#example_input = torch.rand(1, 3, 320, 320) # after test, will get 'size mismatch' error message with size 256x256
#traced_model = torch.jit.trace(model, example_input)
#inputs=[ct.ImageType()]
# Range for the sequence dimension to be between [1, 50]
input_shape = ct.Shape(shape=(1,3, ct.RangeDim(), ct.RangeDim()) )
print(input_shape.shape)
print(example_input.shape)
#shapes = [(1,3, 6*i, 6*i) for i in range(1, 100)]
#input_shape = ct.EnumeratedShapes(shapes=shapes)
#model_input=ct.TensorType(name="image",shape=input_shape)
print("#####"+str(ct.SPECIFICATION_VERSION))
model2 = ct.convert(
model,
#inputs=[ct.TensorType(name="image",shape=example_input.shape)],
inputs=[ct.TensorType(name="image",shape=input_shape.shape)],
#inputs=[ct.TensorType(name="image",shape=input_shape.shape)], //have tried, the same error
#outputs=[ct.ImageType(name="outImage",shape=example_input.shape)],
minimum_deployment_target=ct.target.iOS13,
)

(1, 3, RangeDim(lower_bound=1, upper_bound=-1, default=1, symbol="is0"), RangeDim(lower_bound=1, upper_bound=-1, default=1, symbol="is1"))
torch.Size([1, 3, 320, 320])
#####1
WARNING:root:Tuple detected at graph output. This will be flattened in the converted model.
Converting Frontend ==> MIL Ops: 0% 0/1449 [00:00
minimum_deployment_target=ct.target.iOS13,
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/_converters_entry.py", line 182, in convert
**kwargs
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/converter.py", line 129, in mil_convert
ConverterRegistry, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/converter.py", line 171, in mil_convert_to_proto
prog = frontend_converter(model, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/converter.py", line 85, in __call__
return load(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/frontend/torch/load.py", line 83, in load
raise e
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/frontend/torch/load.py", line 73, in load
prog = converter.convert()
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/frontend/torch/converter.py", line 227, in convert
convert_nodes(self.context, self.graph)
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/frontend/torch/ops.py", line 58, in convert_nodes
_add_op(context, node)
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/frontend/torch/ops.py", line 694, in max_pool2d
_max_pool(context, node, inputs)
File "/usr/local/lib/python3.6/dist-packages/coremltools/converters/mil/frontend/torch/ops.py", line 669, in _max_pool
raise ValueError("@max_pool does not support symbolic input spatial shape when ceil_mode is True")
ValueError: @max_pool does not support symbolic input spatial shape when ceil_mode is True

## ❓Question

## System Information
- If applicable

Contributor guide

Open the contributing guide

Research direction

Start with the reproducer in pth2ml.py and the ct.convert call using a symbolic input_shape. Read the max_pool2d and _max_pool paths in coremltools/converters/mil/frontend/torch/ops.py, where the ValueError is raised. Done means the reported conversion behavior is clarified or the symbolic-shape case has a validated resolution, with the relevant conversion output or test evidence.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.