AllocHostTensor【免费下载链接】opbase本项目是CANN算子库的基础框架库为算子提供公共依赖文件和基础调度能力。项目地址: https://gitcode.com/cann/opbase功能说明申请一个host侧tensor提供多个重载函数可以指定不同的输入属性如不同的数据类型。函数原型根据不同的输入信息组合申请一个host侧tensoraclTensor *AllocHostTensor(const op::Shape shape, op::DataType datatype, op::Format format op::Format::FORMAT_ND)aclTensor *AllocHostTensor(const op::Shape storageShape, const op::Shape originShape, op::DataType dataType, op::Format storageFormat, op::Format originFormat)申请一个host侧tensor将指定数据类型的内存作为该tensor内容aclTensor *AllocHostTensor(const int64_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint64_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const bool *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const char *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const int32_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint32_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const int16_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint16_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const int8_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint8_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const double *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const float *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const fp16_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const bfloat16 *value, uint64_t size, op::DataType dataType)参数说明根据不同的输入信息组合申请一个host侧tensor。参数输入/输出说明shape输入将aclTensor的StorageShape和OriginShape都设置为指定的shape。dataType输入指定aclTensor的数据类型。format输入将aclTensor的StorageFormat和OriginFormat都设置为指定的format。storageShape输入将aclTensor的StorageShape设置为指定shape。originShape输入将aclTensor的OriginShape设置为指定shape。storageFormat输入将aclTensor的StorageFormat设置为指定format。originFormat输入将aclTensor的OriginFormat设置为指定format。申请一个host侧tensor将指定数据类型的内存作为该tensor内容。参数输入/输出说明value输入指向不同数据类型的源数据。size输入源数据的元素个数。dataType输入将源数据转为dataType指定的数据类型后写入tensor。返回值说明返回申请得到的aclTensor申请失败则返回nullptr。约束说明入参指针不能为空。调用示例// 申请一个host侧tensor并将myArray中的数据拷贝到tensor中 void Func(aclOpExecutor *executor) { int64_t myArray[10]; aclTensor *tensor executor-AllocHostTensor(myArray, 10, DT_INT64); }【免费下载链接】opbase本项目是CANN算子库的基础框架库为算子提供公共依赖文件和基础调度能力。项目地址: https://gitcode.com/cann/opbase创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
CANN/opbase分配主机张量API
AllocHostTensor【免费下载链接】opbase本项目是CANN算子库的基础框架库为算子提供公共依赖文件和基础调度能力。项目地址: https://gitcode.com/cann/opbase功能说明申请一个host侧tensor提供多个重载函数可以指定不同的输入属性如不同的数据类型。函数原型根据不同的输入信息组合申请一个host侧tensoraclTensor *AllocHostTensor(const op::Shape shape, op::DataType datatype, op::Format format op::Format::FORMAT_ND)aclTensor *AllocHostTensor(const op::Shape storageShape, const op::Shape originShape, op::DataType dataType, op::Format storageFormat, op::Format originFormat)申请一个host侧tensor将指定数据类型的内存作为该tensor内容aclTensor *AllocHostTensor(const int64_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint64_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const bool *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const char *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const int32_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint32_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const int16_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint16_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const int8_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const uint8_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const double *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const float *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const fp16_t *value, uint64_t size, op::DataType dataType)aclTensor *AllocHostTensor(const bfloat16 *value, uint64_t size, op::DataType dataType)参数说明根据不同的输入信息组合申请一个host侧tensor。参数输入/输出说明shape输入将aclTensor的StorageShape和OriginShape都设置为指定的shape。dataType输入指定aclTensor的数据类型。format输入将aclTensor的StorageFormat和OriginFormat都设置为指定的format。storageShape输入将aclTensor的StorageShape设置为指定shape。originShape输入将aclTensor的OriginShape设置为指定shape。storageFormat输入将aclTensor的StorageFormat设置为指定format。originFormat输入将aclTensor的OriginFormat设置为指定format。申请一个host侧tensor将指定数据类型的内存作为该tensor内容。参数输入/输出说明value输入指向不同数据类型的源数据。size输入源数据的元素个数。dataType输入将源数据转为dataType指定的数据类型后写入tensor。返回值说明返回申请得到的aclTensor申请失败则返回nullptr。约束说明入参指针不能为空。调用示例// 申请一个host侧tensor并将myArray中的数据拷贝到tensor中 void Func(aclOpExecutor *executor) { int64_t myArray[10]; aclTensor *tensor executor-AllocHostTensor(myArray, 10, DT_INT64); }【免费下载链接】opbase本项目是CANN算子库的基础框架库为算子提供公共依赖文件和基础调度能力。项目地址: https://gitcode.com/cann/opbase创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考