昇腾社区首页
中文
注册
开发者
下载

Utils

功能说明

加速库公共工具接口类。

定义

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Utils {
public:
    static std::string GetAtbVersion();
    static uint64_t GetTensorSize(const Tensor &tensor);
    static uint64_t GetTensorSize(const TensorDesc &tensorDesc);
    static uint64_t GetTensorNumel(const Tensor &tensor);
    static uint64_t GetTensorNumel(const TensorDesc &tensorDesc);
    static void QuantParamConvert(const float *src, uint64_t *dest, uint64_t itemCount);
    static Status SetLogLevel(const atb::LogLevel atbLogLevel); 
    static Status ResetLogLevel();
};

成员

成员名称

描述

GetAtbVersion

返回加速库版本信息。

GetTensorSize

返回Tensor对象的数据存储大小。

GetTensorNumel

返回Tensor对象的数据个数。

QuantParamConvert

量化场景使用。float数组转成uint64数组,实现逻辑是复制float到uint64的后32位,uint64的前32位置0。

  • src:输入float数组。
  • dest:转化得到的uint64数组。
  • itemCount:数组元素个数。

SetLogLevel

程序执行过程中设置加速库日志级别

  • atbLogLevel:加速库日志级别。

ResetLogLevel

恢复日志级别到环境变量的设置