An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# pytorch-coreml-custom-layer-example
PyTorch to CoreML: Writing custom layers with Metal

pytorch-demo-image

## 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).