apple / apple/coremltools

Result of Flexible-input-shape Model is NAN

Open
#2,166 4 comments 0 reactions 0 assignees View on GitHub
bug Flexible Shape PyTorch (traced)
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## 🐞Describing the bug
When I using EnumeratedShape or RangeDim to generate a flexible-input-shape model to inference, the result is all nan.

## Stack Trace
```
/opt/homebrew/anaconda3/envs/bce/bin/python /Users/jinmuchuan/projects/BCEmbedding/model.py
torch.int32
When both 'convert_to' and 'minimum_deployment_target' not specified, 'convert_to' is set to "mlprogram" and 'minimum_deployment_targer' is set to ct.target.iOS15 (which is same as ct.target.macOS12). Note: the model will not run on systems older than iOS15/macOS12/watchOS8/tvOS15. In order to make your model run on older system, please set the 'minimum_deployment_target' to iOS14/iOS13. Details please see the link: https://coremltools.readme.io/docs/unified-conversion-api#target-conversion-formats
Tuple detected at graph output. This will be flattened in the converted model.
Converting PyTorch Frontend ==> MIL Ops: 0%| | 0/672 [00:00 MIL Ops: 100%|█████████▉| 670/672 [00:00<00:00, 5151.90 ops/s]
Running MIL frontend_pytorch pipeline: 100%|██████████| 5/5 [00:00<00:00, 458.38 passes/s]
Running MIL default pipeline: 0%| | 0/71 [00:00

Contributor guide

Open the contributing guide

Research direction

Start with the provided Python reproduction and inspect the ct.convert path for PyTorch models using RangeDim, including the flexible input shapes and int32 inputs. Compare the converted model's prediction output with the source model and trace where NaN values first appear; done means the reproduced flexible-shape model produces finite results and the behavior is covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, 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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.