Summary
Checklist of low-priority cleanup items found while reviewing PyTorchSimFrontend/. None are correctness bugs on their own (the real bugs are filed separately in #236, #237, #238, #239, #240). Filing as a single tracking issue for easy batch cleanup.
Dead code
Copy-paste / misleading messages
Style / Pythonic nits
Duplication (templates) — defer if too invasive
The four conv templates (mlir_conv_template.py, mlir_conv_sb_template.py, mlir_conv_sbs_template.py, mlir_conv_mt_template.py) and the gemm/bmm templates share large copy-pasted blocks. Lifting the common pieces into mlir_conv_common.py / mlir_common.py would shrink the surface, but the templates also intentionally diverge (single-batch vs multi-tile vs subtile-stationary variants), so the dedup needs careful design. Filing as a note rather than an action item.
Summary
Checklist of low-priority cleanup items found while reviewing
PyTorchSimFrontend/. None are correctness bugs on their own (the real bugs are filed separately in #236, #237, #238, #239, #240). Filing as a single tracking issue for easy batch cleanup.Dead code
extension_op.py:116-179—generate_inner_product_matrixis 63 lines with no call sites anywhere in the repo. Safe to delete.extension_op.py:285-288—sparse_mm_dummy_stonne_outerusesyield, making it a generator function. It is referenced from the wrapper header inmlir_codegen_backend.pybut is never iterated, so calling it returns a generator object, not the result ofout.copy_. Either drop theyieldor remove the function.extension_codecache.py:249-251—w_offsetis computed conditionally then unconditionally overwritten with0. Drop the dead branch (commented-out original expression suggests this is a known hack).mlir_codegen_backend.py:317, 1410—dma_write_counteris initialized but never incremented; onlydma_read_counteris bumped (line 1407). If MVOUT is always typeMVOUT1, dropdma_write_counterto avoid confusion.Copy-paste / misleading messages
extension_codecache.py:137-139—TileSizeError.__init__default message is"SPAD overflow occurred.", identical toSpadOverflowError's message (copy-paste). Change it to something like"Tile size constraint violated."extension_codecache.py:170, 220—MLIRCodeCache.loadinstantiates twoFileLockobjects against the same lock-file path with a non-locked gap between them. The on-disk file is the actual serialization primitive so there is no race, but folding bothwith lock:blocks under one acquisition is clearer.extension_codecache.py:19-23andmlir_autotune.py:19-23—get_write_pathandhash_prefixare duplicated verbatim across the two modules (the comment notes circular-import avoidance). Move both toextension_config.pyand import from there.Style / Pythonic nits
mlir_common.py:20, 25—import sympyappears twice. Remove the second one.mlir_common.py:556—MLIRMultiDimTile.get_nr_dimis annotated-> strbut returnslen(self._tile_size), anint. Fix the annotation.mlir_scheduling.py:185— bareexcept:swallowsKeyboardInterrupt/SystemExit. Switch toexcept Exception:.mlir_scheduling.py:63—revert_grouphas no return statement, but the caller doesnode1 = self.revert_group(node1)and then never usesnode1again. Drop the assignment or haverevert_groupreturn its argument.extension_codecache.py:155, 270—arg_attributes=[],tile_size=[]mlir_common.py:203, 1153—extra_node=dict(),affine_yield=dict()mlir_scheduling.py:310—origins={}mlir_codegen_backend.py:435—indirect_dims=[]Replace each with
Noneand initialize in the body.print()with the modulelogger. Examples:mlir_codegen_backend.py:486extension_config.py:159extension_op.py:176-178, 187-188mlir_caller_codegen.py:199-200These bypass log-level filtering. Route through
logger(or remove if debug-only).Duplication (templates) — defer if too invasive
The four conv templates (
mlir_conv_template.py,mlir_conv_sb_template.py,mlir_conv_sbs_template.py,mlir_conv_mt_template.py) and the gemm/bmm templates share large copy-pasted blocks. Lifting the common pieces intomlir_conv_common.py/mlir_common.pywould shrink the surface, but the templates also intentionally diverge (single-batch vs multi-tile vs subtile-stationary variants), so the dedup needs careful design. Filing as a note rather than an action item.