SetTensorValue

函数功能

设置Tensor的值,支持int32_t、uint8_t、float16、float32类型。

Tensor对象需在Device侧且数据类型与调用的SetTensorValue方法匹配。

函数原型

APP_ERROR Tensor::SetTensorValue(int32_t value, AscendStream& stream)
APP_ERROR Tensor::SetTensorValue(uint8_t value, AscendStream &stream)
APP_ERROR Tensor::SetTensorValue(float value, bool isFloat16,AscendStream &stream)

参数说明

参数名

输入/输出

说明

value

输入

int32_t、uint8_t、float类型,指定Tensor待设置的值。

isFloat16

输入

bool类型,默认为为“False”

  • “True”时表示设置Tensor元素为floa16类型。
  • “False”时表示设置Tensor元素为floa32类型。

stream

输入

AscendStream类型,默认值为AscendStream::DefaultStream()。当参数值为默认值时,接口为同步操作,其他情况下,接口为异步操作。

返回参数说明

数据结构

说明

APP_ERROR

程序执行返回的错误码,请参考“MxBase/ErrorCode/ErrorCode.h”文件。