根据condition的数据类型,将condition中的元素与True或1比较,如果表达式成立返回x对应的值,否则返回y对应的值。
以下通过表达式的方式来解释如何比较,其中,i是表示condition中的元素,x'表示x的元素或者x,y'表示y的元素或者y,z表示结果tensor的元素,n(取值0~7)表示condition元素的bit位index,表达式如下:
vsel(condition, lhs, rhs)
其中,lhs与rhs的数据类型需要一致。
昇腾310 AI处理器:支持的数据类型有float16
昇腾910 AI处理器:支持的数据类型有float16、float32
昇腾310P AI处理器:支持的数据类型有float16、float32
res_tensor: 结果tensor,tvm.tensor类型
因为bool_storage_as_1bit的默认值为True,表示按照1 bit进行存储。
编译配置config如下所示:
with tvm.target.cce(): schedule = tbe.dsl.auto_schedule(res) config = {"name": kernel_name, "tensor_list": [data_x, data_y, res], "bool_storage_as_1bit": False} tbe.dsl.build(schedule, config)
昇腾310 AI处理器
昇腾910 AI处理器
昇腾310P AI处理器