昇腾社区首页
中文
注册

SelectWithBytesMask Tiling

功能说明

kernel侧SelectWithBytesMask 接口的计算需要开发者申请临时空间,本接口用于在host侧获取申请的最大最小临时空间大小,开发者基于此范围选择合适的空间大小作为Tiling参数传递到kernel侧使用。

  • 为保证功能正确,申请的临时空间大小不能小于最小临时空间大小;
  • 在最小临时空间-最大临时空间范围内,随着临时空间增大,kernel侧接口计算性能会有一定程度的优化提升。为了达到更好的性能,开发者可以根据实际的内存使用情况进行空间申请。

函数原型

inline uint32_t GetSelectWithBytesMaskMinTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uin32_t maskType, const bool isReuseSource);

inline uint32_t GetSelectWithBytesMaskMaxTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uin32_t maskType, const bool isReuseSource);

inline void GetSelectWithBytesMaskMaxMinTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uin32_t maskType, const bool isReuseSource, uint32_t& maxValue, uint32_t& minValue);

参数说明

表1 接口参数列表

接口

输入/输出

功能

src0Shape

输入

输入src0的shape信息。src0为scalar时,shape应为{1}。

src1Shape

输入

输入src1的shape信息。src1为scalar时,shape应为{1}。

srcTypeSize

输入

输入srcTensor的数据类型大小,比如数据类型为half,此处应传入2。

maskShape

输入

输入maskTensor的shape信息。

maskTypeSize

输入

输入maskTensor的数据类型大小,比如数据类型为bool,此处应传入1。

isReuseSource

输入

是否复用maskTensor输入的空间。与kernel侧保持一致。

返回值

GetSelectWithBytesMaskMinTmpSize返回SelectWithBytesMask接口能完成计算所需最小临时空间大小。

GetSelectWithBytesMaskMaxTmpSize返回SelectWithBytesMask接口能完成计算所需最大临时空间大小。

GetSelectWithBytesMaskMaxMinTmpSize无返回值。

调用示例

std::vector<int64_t> shape0Vec = {64, 128};
std::vector<int64_t> shape1Vec = {1};
std::vector<int64_t> mask1Vec = {64, 128};
ge::Shape src0Shape(shape0Vec);
ge::Shape src1Shape(shape1Vec);
ge::Shape maskShape(maskShape);
uint32_t maxValue = 0;
uint32_t minValue = 0;
GetSelectWithBytesMaskMaxMinTmpSize(src0Shape, src1Shape, 2, maskShape, 1, false, maxValue, minValue);