Skip to content

Commit

Permalink
Make 4D output work for task extraction.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Mar 11, 2020
1 parent 9a3b786 commit 5ef694f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
31 changes: 31 additions & 0 deletions python/tvm/contrib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,34 @@ def which(exec_name):
if os.path.isfile(full_path) and os.access(full_path, os.X_OK):
return full_path
return None


def get_lower_ir(s):
"""Get lower ir code of a schedule.
This is useful for debug, since you don't have to find all inputs/outputs
for a schedule in a fused subgraph.
Parameters
----------
s: Schedule
Returns
-------
ir: str
The lower ir
"""
from tvm.te import tensor
from tvm.driver.build_module import lower

outputs = s.outputs

inputs = []
def find_all(op):
if isinstance(op, tensor.PlaceholderOp):
inputs.append(op.output(0))
else:
for x in op.input_tensors:
find_all(x.op)

for out in outputs:
find_all(out)

return lower(s, inputs, simple_mode=True)
8 changes: 7 additions & 1 deletion topi/python/topi/cuda/conv2d_int8.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ def _schedule_conv2d_NCHWc_int8(cfg, s, output):
output = s.outputs[0].output(0)

# tile and bind spatial axes
n, f, y, x, c = s[output].op.axis
if len(s[output].op.axis) == 5:
n, f, y, x, c = s[output].op.axis
else:
# For task extraction of auto-tuning, the expected output is 4D. Since auto-tuning tasks
# are created from scratch, therefore the real auto-tuning will still happen on 5D output.
n, f, y, x = s[output].op.axis

cfg.define_split("tile_n", cfg.axis(n), num_outputs=4)
cfg.define_split("tile_f", cfg.axis(f), num_outputs=4)
cfg.define_split("tile_y", cfg.axis(y), num_outputs=4)
Expand Down

0 comments on commit 5ef694f

Please sign in to comment.