Comments (5)
I checked the torch model, find no layer's input/output contains number beyond 65504.
Two possible reasons:
- The model underflow with fp16.
- Some intermediate results overflow with fp16. Even each torch layer's input/output is within fp16 range, the converted model could still overflow on some intermediate tensors (because the op in torch and op in CoreML is not strictly 1:1 mapping).
I would recommend to use "binary search" to find which op is the culprit: Get the first half of the torch model, convert it and see if results match; And then keep halfing the part which introduces the numerical issue.
from coremltools.
Now I located the problem caused by https://github.com/TencentARC/GFPGAN/blob/master/gfpgan/archs/stylegan2_clean_arch.py , but binary search
is time-consuming, any suggestion for this arch?
from coremltools.
#1671. same problem
from coremltools.
Thank you for locating the culprit part in the model!
Yeah it's the same issue you mentioned, due to fp16 intermediate results overflow.
If you want to try it on GPU, one method to try is changing the compute precision by compute_precision=ct.precision.FLOAT32
in ct.convert
. Here is an example: https://apple.github.io/coremltools/docs-guides/source/convert-to-ml-program.html?highlight=compute_precision#set-the-ml-program-precision.
Then profiling the converted model by Xcode to see if it's GPU resident.
from coremltools.
@junpeiz fp32 model on GPU works fine, thanks, issue close.
from coremltools.
Related Issues (20)
- linear_quantize_weights make wrong result in GPU / ANE HOT 7
- RuntimeError: PyTorch convert function for op 'lift_fresh' not implemented. HOT 3
- Failed in runing predict() for Activation quantization model : Unknown opset 'CoreML7' HOT 2
- Is the Palettization diagram in the apple github wrong values? HOT 3
- Error when installing Tensorflow from “Getting Started” page. HOT 3
- Is it possible to add support for Kosmos-2 Model HOT 2
- Assertion fails when torch.mean is called with dtype argument. HOT 3
- Documentation does not show iOS16 ops for conv and conv_transpose HOT 9
- Support for Yolov8 OBB! - Oriented Bounding Box detection HOT 3
- Python 3.12 Support HOT 6
- Input error during converting torch.fft.irfft HOT 4
- Meet error when convert lama with flexable input shape!!! HOT 2
- Do Quantization/Palettization affect the parameter count? HOT 1
- Runtime error, op 'tensordot' not implemented.
- [ExecuTorch] EXIR Converter Broken by ExecuTorch PR 1802
- index_put failing when indices are bool type HOT 1
- CI Github macos ARM HOT 2
- Easy way to determine which graph passes get applied
- Experiencing "divided by two must all be the same length" when trying to convert a PyTorch MaxPool2d
- XlaCallModule or another way of loading StableHLO code HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coremltools.