#!/bin/bash # 由 ab_repeat.sh 与 screen.sh 共用;两处必须用同一个判据,否则筛选放行的算子 # 到了 A/B 那步又被拦下,或者反过来。 # 一个 run 生成代码的指纹:只取 .ttgir 的相对路径 + 内容,并先抹掉开关自己盖上去的 # 注解。 # # 只认 .ttgir:dump 目录里还有 index.tsv 和 naming.md,一个 kernel 都没编出来的 run # 只剩这两个文件、两侧完全相同,会把"什么都没生成"报成"开关没改变生成代码"。 # # 抹掉 ttg.rlc-*:FlagTree 的 _apply_musa_rlc_policy(mod) 在开关打开时把整套 RLC 策略 # 旋钮盖成 module 属性,跟这个 pass 后面有没有真的改动什么无关。不抹的话判据有个常量 # 偏移——凡是能编出 kernel 的算子都必然判成"变了",筛选器谁都不排除。实测 24 个算子 # 里有 7 个(tanh gelu mul softmax mm bmm replication_pad3d)除这行属性外逐字节相同。 # 零对照抓不到它:两侧同值时属性也相同。 # # 零 kernel 返回非零,交给调用方当作"没有可比的 IR",而不是"一致"。 ir_fingerprint() { local dir="$1/ttgir" [[ -d "$dir" ]] || return 1 local n n=$(find "$dir" -name '*.ttgir' -type f 2>/dev/null | wc -l) (( n > 0 )) || return 1 local out out=$( { find "$dir" -name '*.ttgir' -type f | LC_ALL=C sort | while IFS= read -r f; do printf '%s ' "${f#"$dir"/}" sed -E 's/"ttg[.]rlc-[^"]*" = [0-9-]+ : i32, ?//g' "$f" done; } | sha256sum | cut -d' ' -f1 ) [[ -n "$out" ]] && printf '%s' "$out" }