https://github.com/dneprdroid/pytorch-coreml-custom-layer-example
PyTorch to CoreML: Writing custom layers with Metal shaders - torch.nn.functional.grid_sample operation
https://github.com/dneprdroid/pytorch-coreml-custom-layer-example
coreml coremltools ios metal ml pytorch swift
Last synced: 11 months ago
JSON representation
PyTorch to CoreML: Writing custom layers with Metal shaders - torch.nn.functional.grid_sample operation
- Host: GitHub
- URL: https://github.com/dneprdroid/pytorch-coreml-custom-layer-example
- Owner: dneprDroid
- Created: 2021-12-11T08:38:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-04T10:43:50.000Z (about 2 years ago)
- Last Synced: 2025-07-10T10:16:17.920Z (12 months ago)
- Topics: coreml, coremltools, ios, metal, ml, pytorch, swift
- Language: Swift
- Homepage: https://medium.com/@ovechko.056/pytorch-to-coreml-writing-custom-layers-with-metal-e8922b51895
- Size: 25.7 MB
- Stars: 16
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pytorch-coreml-custom-layer-example
PyTorch to CoreML: Writing custom layers with Metal

## Convert PyTorch model
```bash
cd Convert
python3 -m pip install -r requirements.txt
python3 convert.py -o /path/to/output/resulting/mlmodel/file
```
## Run the demo app
Open `TorchCoreMLDemo.xcodeproj` in Xcode, build and run the app.
## Shader
The code of the grid sample Metal-shader is [here](./TorchCoreMLDemo/TorchCoreMLDemo/Metal/GridSample.metal).
More information about grid sample (warper) algorithm you can find [here](https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html).