TorchedUp
ProblemsPremium
TorchedUp
Identify Fusable ChainsMedium
ProblemsPremium

Identify Fusable Chains

Given a list of ops with kinds in {'gemm', 'elementwise', 'reduction', 'memory'}, group consecutive indices that can fuse into a single kernel.

Signature: def identify_fusable_chain(ops: list) -> list

  • ops: list of {'kind': str} dicts
  • Fusion rules:
    • elementwise → elementwise: fuse
    • gemm → elementwise: fuse (epilogue fusion)
    • any reduction or memory op breaks the chain — it stands alone
    • any other transition breaks the chain

Return a list of lists of indices, in order.

Example: [gemm, elementwise, elementwise, reduction, elementwise] → [[0, 1, 2], [3], [4]].

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○gemm + elementwise epilogue
○all elementwise
○memory breaks chain🔒 Premium
Advertisement