mindspore_lite.AscendDeviceInfo

class mindspore_lite.AscendDeviceInfo(device_id=0)[源代码]

用于描述Ascend设备硬件信息的辅助类,继承 mindspore_lite.DeviceInfo 基类。

参数:
  • device_id (int,可选) - 设备id。默认值:0。

异常:
  • TypeError - device_id 不是int类型。

  • ValueError - device_id 小于0。

样例:

>>> # Use case: inference on Ascend device.
>>> # precondiction 1: Building MindSpore Lite Ascend package on Ascend device.
>>> # precondiction 2: install wheel package of MindSpore Lite built by precondiction 1.
>>> import mindspore_lite as mslite
>>> ascend_device_info = mslite.AscendDeviceInfo(device_id=0)
>>> print(ascend_device_info)
device_type: DeviceType.kAscend,
device_id: 0.
>>> cpu_device_info = mslite.CPUDeviceInfo(enable_fp16=False)
>>> context = mslite.Context()
>>> context.append_device_info(ascend_device_info)
>>> context.append_device_info(cpu_device_info)
>>> print(context)
thread_num: 0,
inter_op_parallel_num: 0,
thread_affinity_mode: 0,
thread_affinity_core_list: [],
enable_parallel: False,
device_list: 3, 0, .