Download conversion/ct_patch.py from FluidInference/vela-3.0-coreml: direct link, hf CLI and curl.
- Browser
- Download file 599 Bytes
-
https://huggingface.co/FluidInference/vela-3.0-coreml/resolve/main/conversion/ct_patch.py
- Command line
-
hf download hf://FluidInference/vela-3.0-coreml/conversion/ct_patch.py
-
curl -L -o ct_patch.py https://huggingface.co/FluidInference/vela-3.0-coreml/resolve/main/conversion/ct_patch.py
599 Bytes
| """coremltools 9 + numpy 2: the torch frontend's _cast folds 1-element constants with int(array([n])), which numpy 2 rejects.""" | |
| import numpy as np | |
| from coremltools.converters.mil.frontend.torch import ops as _ops | |
| _cast0 = _ops._cast | |
| def _cast(context, node, dtype, dtype_name): | |
| x = _ops._get_inputs(context, node, expected=1)[0] | |
| if x.can_be_folded_to_const() and np.ndim(x.val) > 0 and np.size(x.val) == 1: | |
| context.add(_ops.mb.const(val=dtype(np.asarray(x.val).item()), name=node.name), node.name) | |
| return | |
| _cast0(context, node, dtype, dtype_name) | |
| _ops._cast = _cast | |