| Files | Last commit | Last update |
|---|---|---|
| 3 months ago | ||
| 3 months ago | ||
| 2 months ago | ||
| 21 days ago | ||
| 21 days ago | ||
| 19 days ago | ||
| 1 month ago |
PyPTO Sample Code (Examples)
English | 简体中文
This directory contains a series of PyPTO development sample codes designed to guide developers on how to use this AI programming framework. The sample codes progressively demonstrate the framework's features based on the developer's learning path.
Directory Structure
The sample codes are divided into the following levels:
- 00_hello_world (Getting Started): Simple tensor addition, a Hello World sample suitable for beginners to understand framework initialization.
- 01_beginner (Beginner): Basic operations and core concepts, suitable for developers new to PyPTO.
- 02_intermediate (Intermediate): Neural network components, operator combinations, and Runtime features.
- 03_advanced (Advanced): Complex architectures (such as Attention), advanced patterns, and system-level optimization.
Quick Start
- First time user? Start from Beginner Samples (01_beginner).
- Building a neural network? Refer to Intermediate Samples (02_intermediate).
- Exploring advanced patterns? Refer to Advanced Samples (03_advanced).
Environment Preparation
For environment preparation, refer to Environment Setup to complete the basic environment setup.
Software Installation
For software installation, refer to Software Installation to complete the PyPTO software installation.
Pre-Run Configuration (Optional)
If you need to run in a real NPU environment, refer to the following configuration:
# Configure CANN environment variables
# After installation, configure the environment variables. Execute the following command based on the actual path of set_env.sh.
# The above environment variable configuration only takes effect in the current window. You can write the above commands into the environment variable configuration file (such as .bashrc) as needed.
# Default path installation, using root user as a sample (for non-root users, replace /usr/local with ${HOME})
source /usr/local/Ascend/ascend-toolkit/set_env.sh
# Set NPU device ID (required when running NPU samples)
export TILE_FWK_DEVICE_ID=0
How To Run Samples
Most sample scripts support running all tests or specifying a specific test:
# Run all beginner basic operation samples (default is NPU mode)
python3 examples/01_beginner/basic/basic_ops.py
# Run a specific sample
python3 examples/01_beginner/basic/basic_ops.py --tests matmul
# Show all available samples and options
python3 examples/01_beginner/basic/basic_ops.py --help
# Specify simulation (CPU) mode
python3 examples/01_beginner/basic/basic_ops.py --run_mode sim
Learning Path Suggestions
-
Phase 1: Build a Solid Foundation
-
Phase 2: Advanced Components
-
Phase 3: In-Depth Practice
Wishing you a fruitful programming journey with PyPTO!