---
title: Utils
description: "加速库公共工具接口类。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_01_0097.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_01_0097.html
indexId: aabb979067685bfd28805007e453f0cda4ed65230e5d6771c935c8d455a26b7464
---
# Utils

#### 功能说明

加速库公共工具接口类。


#### 定义

```
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 | 恢复日志级别到环境变量的设置。 |
