Contents

Customizing a PyTorch operation

Implement a custom operation in PyTorch that uses Metal kernels to improve performance.

Overview

Configure the sample code project

Before you run the sample code project:

  1. Follow the instructions in Accelerated PyTorch training on Mac.

  2. Install PyTorch nightly (Python 3.7 or later is required).

pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
  1. Install Ninja

pip3 install Ninja
  1. Run the sample.

python3 run_sample.py

See Also

Compute workflows