Skip to content

Update type_mapping.py #1810

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update type_mapping.py #1810

wants to merge 1 commit into from

Conversation

reddyn12
Copy link

Add support for np.intc. It's the same as np.int32.

Add support for np.intc. It's the same as np.int32.
@TobyRoseman
Copy link
Collaborator

@reddyn12 - thanks for the PR. Did this fix a problem you were having?

CI: https://gitlab.com/coremltools1/coremltools/-/pipelines/819624143

@reddyn12
Copy link
Author

@TobyRoseman Ya, I'm trying to run transformers on the ANE, but had a problem with the intc type. I'm using Karpathy's implementation. Now I'm getting " File "/usr/local/lib/python3.11/site-packages/coremltools/converters/mil/backend/mil/load.py", line 279, in load
raise RuntimeError("BlobWriter not loaded")
RuntimeError: BlobWriter not loaded"

I ran the program on both my Windows pc and Mac. I'm using the code provided with the Transformers article on Apple ML website: https://machinelearning.apple.com/research/neural-engine-transformers

@reddyn12
Copy link
Author

https://github.com/reddyn12/ANEFinesse is the exact code I'm using. TorchScriptConv.py is the file.

@TobyRoseman
Copy link
Collaborator

@reddyn12 - thanks for the explanation. If you could add a unit test, that would be great.

@YifanShenSZ
Copy link
Collaborator

Hey @reddyn12, the unit test can be added to test_types.py, as a method of class TestTypeMapping. Something like

def test_numpy_int_to_coremltools(self):
    assert numpy_type_to_builtin_type(np.int32) == types.int32
    assert numpy_type_to_builtin_type(np.intc) == types.int32

should be good, thanks!

@YifanShenSZ YifanShenSZ mentioned this pull request Apr 7, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants