Giter Club home page Giter Club logo

Comments (5)

junpeiz avatar junpeiz commented on June 30, 2024

I checked the torch model, find no layer's input/output contains number beyond 65504.
Two possible reasons:

  1. The model underflow with fp16.
  2. 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.

ykk648 avatar ykk648 commented on June 30, 2024

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.

ykk648 avatar ykk648 commented on June 30, 2024

#1671. same problem

from coremltools.

junpeiz avatar junpeiz commented on June 30, 2024

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.

ykk648 avatar ykk648 commented on June 30, 2024

@junpeiz fp32 model on GPU works fine, thanks, issue close.

from coremltools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.