---
title: Customizing a TensorFlow operation
framework: metal
role: sampleCode
role_heading: Sample Code
path: sample-code/metal/customizing-a-tensorflow-operation
---

# Customizing a TensorFlow operation

Implement a custom operation that uses Metal kernels to accelerate neural-network training performance.

## Overview

Overview note: This sample code project is associated with WWDC22 session 10063: Accelerate machine learning with Metal. Configure the sample code Follow the instructions in Getting started with tensorflow-metal. Install ffmpeg using brew. brew install ffmpeg Install the required Python packages. pip install -r requirements.txt Use make to build the custom operation with Xcode. cd hash_encoder make cd .. Run the sample. python tiny_nerf_hash.py View the resutls in the result_nerf_hash folder. To compare the performance benefits provided by this sample, you can run the original NeRF sample code included with the project.  View the resutls in the result_nerf_mlp folder. python tiny_nerf_mlp.py note: The sample uses low-resolution (100x100) images by default. You can alternatively use a high-resolution version of the data to produce a clearer rendering.

## See Also

### Compute workflows

- [Performing calculations on a GPU](metal/performing-calculations-on-a-gpu.md)
- [Selecting device objects for compute processing](metal/selecting-device-objects-for-compute-processing.md)
- [Customizing a PyTorch operation](metal/customizing-a-pytorch-operation.md)
