GetPowerMaxMinTmpSize
功能说明
kernel侧Power接口的计算需要开发者预留/申请临时空间,本接口用于在host侧获取预留/申请的最大和最小临时空间大小,开发者基于此范围选择合适的空间大小作为Tiling参数传递到kernel侧使用。
- 为保证功能正确,预留/申请的临时空间大小不能小于最小临时空间大小;
- 在最小临时空间-最大临时空间范围内,随着临时空间增大,kernel侧接口计算性能会有一定程度的优化提升。为了达到更好的性能,开发者可以根据实际的内存使用情况进行空间预留/申请。
接口内部根据srcShape1、srcShape2输入判断接口为Power(dstTensor, srcTensor1, srcTensor2)、Power(dstTensor, srcTensor1, scalarValue) 或Power(dstTensor, scalarValue, srcTensor2)类型中的哪一种,进而返回对应临时空间大小。
函数原型
void GetPowerMaxMinTmpSize(const ge::Shape& srcShape1, const ge::Shape& srcShape2, const bool typeIsInt, const uint32_t typeSize, const bool isReuseSource, uint32_t& maxValue, uint32_t& minValue)
参数说明
表 1 接口参数列表
返回值说明
无
约束说明
无
调用示例
完整的调用样例请参考更多样例。
-
Power(dstTensor, srcTensor1, srcTensor2)样例
// srcTensor1、srcTensor2输入shape信息均为512;算子输入的数据类型为float;不允许修改源操作数 std::vector<int64_t> shape_vec = {1024}; ge::Shape shape(shape_vec); uint32_t maxValue = 0; uint32_t minValue = 0; AscendC::GetPowerMaxMinTmpSize(shape, shape, false, 4, false, maxValue, minValue); -
Power(dstTensor, srcTensor1, scalarValue)样例
// srcTensor1输入shape信息为128*128,scalarValue的shape为1;算子输入的数据类型为half;不允许修改源操作数 std::vector<int64_t> shape1_vec = {128,128}; std::vector<int64_t> shape2_vec = {1}; ge::Shape shape1(shape1_vec); ge::Shape shape2(shape2_vec); uint32_t maxValue = 0; uint32_t minValue = 0; AscendC::GetPowerMaxMinTmpSize(shape1, shape2, false, 2, false, maxValue, minValue); -
Power(dstTensor, scalarValue, srcTensor2)样例
//scalarValue的shape为1,srcTensor2输入shape信息为128*128;算子输入的数据类型为float;不允许修改源操作数 std::vector<int64_t> shape1_vec = {1}; std::vector<int64_t> shape2_vec = {128,128}; ge::Shape shape1(shape1_vec); ge::Shape shape2(shape2_vec); uint32_t maxValue = 0; uint32_t minValue = 0; AscendC::GetPowerMaxMinTmpSize(shape1, shape2, false, 4, false, maxValue, minValue);