sophon_ai_project/docs/sail_api/4.设备句柄.md
2025-10-17 16:30:24 +08:00

52 lines
640 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 设备句柄
Handle是设备句柄的包装类在程序中用于设备的标识。
## \_\_init\_\_
初始化 Handle
**接口形式:**
```python
def __init__(self, tpu_id: int)
```
**参数说明:**
- tpu_id: int
创建 Handle 使用的TPU的id号
## get_device_id
获取 Handle 中 TPU的id
**接口形式:**
```python
def get_device_id(self) -> int
```
**返回值说明:**
- tpu_id: int
Handle 中的 TPU 的 id 号
## get_sn
获取 Handle 中标识设备的序列码
**接口形式:**
```python
def get_sn(self) -> str
```
**返回值说明**
- serial_number: str
返回 Handle 中设备的序列码