AITensorFactory::CreateTensor
创建模型tensor。该接口在ai_tensor.h中定义。
函数格式
std::shared_ptr<IAITensor> CreateTensor(const AITensorDescription &tensor_desc, void *buffer, int32_t size);
std::shared_ptr<IAITensor> CreateTensor(const AITensorDescription &tensor_desc);
std::shared_ptr<IAITensor> CreateTensor(const std::string &type);
参数说明
参数 |
说明 |
取值范围 |
---|---|---|
tensor_desc |
tensor描述。 关于AITensorDescription数据类型的定义,请参见AITensorDescription。 |
- |
buffer |
数据地址。
说明:
|
- |
size |
数据长度。
说明:
单位为字节,size必须与数据实际大小一致。 |
- |
type |
注册Tensor时的类型。 说明: 该接口不分配内存,在非预分配内存情况下使用。请参见AITensorDescription中type描述。 |
- |
返回值
创建模型tensor成功,则返回tensor指针。创建模型tensor失败,则返回空指针。