Skip to content

Commit

Permalink
structure comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorendumoulin committed Nov 22, 2023
1 parent 2e457f1 commit 9adec28
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions compiler/transforms/dispatch_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
class DispatchRegionsRewriter(RewritePattern):
@op_type_rewrite_pattern
def match_and_rewrite(self, func_op: func.FuncOp, rewriter: PatternRewriter):
"""Helper function to create dispatches in a block. If an operation is
dispatchable according to dispatch_rule, this function will enclose it in
an scf.if block based on the condition core_cond"""

def dispatcher(block: Block, core_cond: builtin.i1, dispatch_rule: Callable):
"""Helper function to create dispatches in a block. If an operation is
dispatchable according to dispatch_rule, this function will enclose it in
an scf.if block based on the condition core_cond"""

# return if the dispatcher made any changes
changes_made = False

Expand Down Expand Up @@ -58,18 +58,16 @@ def dispatcher(block: Block, core_cond: builtin.i1, dispatch_rule: Callable):

return changes_made

""" Rule to dispatch operations to the dm core:
for now, this is only memref copy operations """

def dispatch_to_dm(op):
"""Rule to dispatch operations to the dm core:
for now, this is only memref copy operations"""
if isinstance(op, memref.CopyOp):
return True
return False

""" Rule to dispatch operations to the dm core:
for now, this is only linalg generic operations """

def dispatch_to_compute(op):
"""Rule to dispatch operations to the dm core:
for now, this is only linalg generic operations"""
if isinstance(op, linalg.Generic):
return True
return False
Expand Down

0 comments on commit 9adec28

Please sign in to comment.