Skip to main content

Module device

Module device 

Source
Expand description

Device handling for Python bindings

This module provides PyO3 bindings for ToRSh device types, allowing Python code to specify and manage computational devices (CPU, CUDA, Metal, etc.).

§Examples

import torsh

# Create devices
cpu = torsh.PyDevice("cpu")
cuda = torsh.PyDevice("cuda:0")
metal = torsh.PyDevice("metal:0")

# Check device properties
print(cpu.type)    # "cpu"
print(cuda.index)  # 0

Structs§

PyDevice
Python wrapper for ToRSh devices

Functions§

parse_device
Helper function to parse device from Python arguments
register_device_constants
Register device constants and utility functions with the Python module.