Class DeviceInfoContext
#include <context.h>
DeviceInfoContext类定义不同硬件设备的环境信息。
构造函数
DeviceInfoContext()
析构函数
virtual ~DeviceInfoContext() = default
公有成员变量
struct Data
数据。
公有成员函数
函数 |
云侧推理是否支持 |
端侧推理是否支持 |
|---|---|---|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
void SetAllocator(const std::shared_ptr<Allocator> &allocator) |
✕ |
✕ |
✕ |
✕ |
GetDeviceType
virtual enum DeviceType GetDeviceType() const = 0
获取该DeviceInfoContext的类型。
返回值
该DeviceInfoContext的类型。
enum DeviceType { kCPU = 0, kGPU, kKirinNPU, kAscend910, kAscend310, // add new type here kInvalidDeviceType = 100, };
Cast
template <class T>
std::shared_ptr<T> Cast()
在打开-fno-rtti编译选项的情况下提供类似RTTI的功能,将DeviceInfoContext转换为T类型的指针,若转换失败返回nullptr。
返回值
转换后
T类型的指针,若转换失败则为nullptr。
GetProvider
inline std::string GetProvider() const
获取设备的生产商名。
SetProvider
inline void SetProvider(const std::string &provider)
设置设备生产商名。
参数
provider: 生产商名。
GetProviderDevice
inline std::string GetProviderDevice() const
获取生产商设备名。
SetProviderDevice
inline void SetProviderDevice(const std::string &device)
设置设备生产商设备名。
参数
device: 设备名。
SetAllocator
void SetAllocator(const std::shared_ptr<Allocator> &allocator)
设置内存管理器。
参数
allocator: 内存管理器。
GetAllocator
std::shared_ptr<Allocator> GetAllocator() const
获取内存管理器。