Component
PTODSL
Description
PTODSL 的 pto.select 中,传入带符号或无符号整数时,返回值的类型却丢失了符号标记
例如传入 pto.si32,返回结果的类型是 pto.i32;pto.ui32 同样会变成 pto.i32
这个类型丢失会连带影响依赖类型一致性的地方
实际观察到的场景:simt_allreduce_sum(threads=64,跨 warp 路径)内部用 br.assign 合并 if/else 两个分支的结果,一侧来自 pto.select(pto.i32),另一侧是 pto.si32 常量,br.assign 要求两侧类型一致,于是整个编译以类型不匹配失败(pto.ui32 输入也对应报 pto.i32 与 pto.ui32 不匹配)
Reproduction (minimal)
from ptodsl import pto
from ptodsl._surface_values import unwrap_surface_value
@pto.jit(name="kernel", kernel_kind="vector", target="a5", mode="explicit")
def kernel(A: pto.ptr(pto.i32, "gm")):
pto.init_core()
with pto.simt(32, 1, 1):
a = pto.cast(pto.get_tid_x(), pto.si32)
b = pto.const(0, dtype=pto.si32)
c = pto.select(a > b, a, b)
print("operand types:", unwrap_surface_value(a).type, ",", unwrap_surface_value(b).type)
print("select result :", unwrap_surface_value(c).type)
assert unwrap_surface_value(c).type == pto.si32, "select lost signedness"
pto.store(pto.cast(c, pto.i32), A, 0)
kernel.compile()
print("compiled")
Expected behavior
pto.select 返回结果和传入的 pto.si32 或 pto.ui32 参数保持相同的类型
PTODSL 正常编译通过
Actual behavior / error logs
operand types: si32 , si32
select result : i32
AssertionError: select lost signedness
下游影响(threads=64 的 simt_allreduce_sum,传入 pto.si32,pto.select 结果与 pto.si32 常量在 br.assign 处合并):
RuntimeError: br.assign(...) type mismatch for 'stage4_result': then branch yields i32, else branch yields si32
Git commit
0a3e017
Host platform
Linux (x86_64)
Target Ascend arch (if relevant)
a5
PTOAS build level (if relevant)
None
Component
PTODSL
Description
PTODSL 的
pto.select中,传入带符号或无符号整数时,返回值的类型却丢失了符号标记例如传入
pto.si32,返回结果的类型是pto.i32;pto.ui32同样会变成pto.i32这个类型丢失会连带影响依赖类型一致性的地方
实际观察到的场景:
simt_allreduce_sum(threads=64,跨 warp 路径)内部用br.assign合并 if/else 两个分支的结果,一侧来自pto.select(pto.i32),另一侧是pto.si32常量,br.assign要求两侧类型一致,于是整个编译以类型不匹配失败(pto.ui32输入也对应报pto.i32与pto.ui32不匹配)Reproduction (minimal)
Expected behavior
pto.select返回结果和传入的pto.si32或pto.ui32参数保持相同的类型PTODSL 正常编译通过
Actual behavior / error logs
下游影响(threads=64 的
simt_allreduce_sum,传入pto.si32,pto.select结果与pto.si32常量在br.assign处合并):Git commit
0a3e017
Host platform
Linux (x86_64)
Target Ascend arch (if relevant)
a5
PTOAS build level (if relevant)
None