Skip to content

Commit

Permalink
update traverse inline logic for arm cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi committed Aug 6, 2018
1 parent a3351f1 commit b6b35f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
5 changes: 1 addition & 4 deletions topi/python/topi/arm_cpu/conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ def decl_spatial_pack(cfg, data, kernel, strides, padding, layout, out_dtype):
def schedule_conv2d_nchw_arm_cpu(cfg, outs):
"""TOPI schedule callback"""
s = tvm.create_schedule([x.op for x in outs])
scheduled_ops = []

def _callback(op):
# schedule conv2d
if 'spatial_conv_output' in op.tag and op not in scheduled_ops:
if 'spatial_conv_output' in op.tag:
output = op.output(0)
conv = op.input_tensors[0]

Expand All @@ -65,8 +64,6 @@ def _callback(op):
output = op.output(0)
_schedule_winograd(cfg, s, output, outs[0])

scheduled_ops.append(op)

traverse_inline(s, outs[0].op, _callback)
return s

Expand Down
26 changes: 17 additions & 9 deletions topi/python/topi/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,33 @@

from . import tag

def traverse_inline(s, op, callback):
def traverse_inline(s, final_op, callback):
"""Traverse computation graph and do auto inline
Parameters
----------
s: schedule
The schedule
op: Operation
final_op: Operation
The final output operator.
callback: callable
The callback function on each op
"""
if tag.is_injective(op.tag):
if op not in s.outputs:
s[op].compute_inline()
for tensor in op.input_tensors:
if tensor.op.input_tensors:
traverse_inline(s, tensor.op, callback)
callback(op)
visited = set()

def _traverse(op):
if op in visited:
return
visited.add(op)
if tag.is_injective(op.tag):
if op not in s.outputs:
s[op].compute_inline()
for tensor in op.input_tensors:
if tensor.op.input_tensors:
_traverse(tensor.op)
callback(op)

_traverse(final_op)


def prod(x):
Expand Down

0 comments on commit b6b35f7

Please sign in to comment.