TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

186. Identify Fusable Chains

Medium

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

groups={[i0​,...,ik​]:all consecutive pairs fusable}

Asked at

NumPy

import numpy as np

 

def identify_fusable_chain(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?