Download python/cmlpatch.py from Sanami/haas-ja-coreml: direct link, hf CLI and curl.
- Browser
- Download file 551 Bytes
-
https://huggingface.co/Sanami/haas-ja-coreml/resolve/main/python/cmlpatch.py
- Command line
-
hf download hf://Sanami/haas-ja-coreml/python/cmlpatch.py
-
curl -L -o cmlpatch.py https://huggingface.co/Sanami/haas-ja-coreml/resolve/main/python/cmlpatch.py
551 Bytes
| """coremltools 9.0 workaround: aten::Int on a 1-element const array fails in _cast.""" | |
| import numpy as np | |
| from coremltools.converters.mil.frontend.torch import ops as _ops | |
| _orig_cast = _ops._cast | |
| def _cast(context, node, dtype, dtype_name): | |
| x = _ops._get_inputs(context, node)[0] | |
| if x.val is not None and getattr(x.val, "shape", ()) != () and np.size(x.val) == 1: | |
| context.add(_ops.mb.const(val=dtype(np.asarray(x.val).item()), name=node.name)) | |
| return | |
| return _orig_cast(context, node, dtype, dtype_name) | |
| _ops._cast = _cast | |