Normalize the primfunc to normal form
(sch: s_tir.Schedule)
| 288 | |
| 289 | |
| 290 | def normalize_prim_func(sch: s_tir.Schedule) -> list[SBlockInfo] | None: |
| 291 | """Normalize the primfunc to normal form""" |
| 292 | try: |
| 293 | result = _normalize_prim_func(sch) |
| 294 | if result is None: |
| 295 | return None |
| 296 | except Exception: # pylint: disable=broad-except |
| 297 | return None |
| 298 | |
| 299 | def _iter_kind(i: tirx.IterVar) -> str: |
| 300 | return { |
| 301 | tirx.IterVar.DataPar: "S", |
| 302 | tirx.IterVar.CommReduce: "R", |
| 303 | }.get(i.iter_type, "O") |
| 304 | |
| 305 | blocks: list[SBlockInfo] = [] |
| 306 | for block, loops, iters, is_reduction in zip(*result): |
| 307 | blocks.append( |
| 308 | SBlockInfo( |
| 309 | name=sch.get(block).name_hint, |
| 310 | iters=[ |
| 311 | IterInfo( |
| 312 | kind=_iter_kind(iter), # type: ignore |
| 313 | var=iter.var, |
| 314 | dom=iter.dom.extent, |
| 315 | loop_rv=loop, |
| 316 | ) |
| 317 | for loop, iter in zip(loops, iters) |
| 318 | ], |
| 319 | block_rv=block, |
| 320 | reduction_block=is_reduction, |
| 321 | ) |
| 322 | ) |
| 323 | return blocks |
| 324 | |
| 325 | |
| 326 | def get_sblock_info(sch: s_tir.Schedule, block: s_tir.schedule.SBlockRV) -> SBlockInfo: |
no test coverage detected
searching dependent graphs…