Tutorials
This section provides a collection of Python tutorials designed to help you get started with TT-NN for tasks such as tensor operations, model conversion, and inference.
To run these tutorials smoothly, we recommend using a Python virtual environment with the necessary dependencies installed. You can set this up in one of two ways:
Full Development Environment: Follow the instructions in the TT-NN / TT-Metal Installation Guide to set up the complete development environment.
Lightweight Tutorial Environment: Use the provided Python Environment Setup Script to create a minimal virtual environment specifically for running the tutorials.
Each tutorial also has an equivalent standalone Python script that you can run locally. These scripts are located in the ttnn/tutorials/basic_python/ directory of the TT-Metal repository.
With your virtual environment activated, you can run the tutorials directly:
$ python3 --version
Python 3.10.12
$ python3 example.py
...
Available tutorials:
- Add Tensors
- Basic Tensor Operations
-
Matrix Multiplication
- Import Libraries
- Open the Device
- Tensor Configuration
- Initialize tensors a and b with random values
- Matrix multiply tensor a and b
- Inspect the layout of matrix multiplication output
- Inspect the result of the matrix multiplication
- Matrix multiply tensor a and b by using more performant config
- Close the device
- Full Example and Output
- MLP Inference
- Multi-Head Attention
- Basic Convolution
- Running a Simple CNN Inference on CIFAR-10
-
Building CLIP Model for Zero-Shot Image Classification with TT-NN
- What CLIP Does
- Imports and Dependencies
- TT-NN Device Management and Utility Functions
- Model Weight Conversion
- Generic Transformer Implementation
- Vision Transformer Implementation
- Complete CLIP Model Implementation
- Image Preprocessing
- Image Download Utility
- Model and Tokenizer downloading
- Running CLIP Inference
- TT-NN Visualizer
- TT-NN Tracer and BERT Model Visualization Tutorial
- Example 1: Tracing PyTorch Operations
- Example 2: Tracing TT-NN Tensor Operations
- Example 3: Tracing a BERT Layer