Skip to content

Commit

Permalink
[AutoTVM] Minor bug fixes in AutoTVM for QNN graphs (apache#4797)
Browse files Browse the repository at this point in the history
* [AutoTVM] Minor bug fixes in AutoTVM for QNN graphs.

* Bring back strided_slice.

* Replace tvm.nd change.
  • Loading branch information
anijain2305 authored and alexwong committed Feb 28, 2020
1 parent d1d6550 commit 2d6f6a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ def _traverse_expr(node):
for i, input_idx in enumerate(node_entry["inputs"]):
input_node_entry = node_list[input_idx[0]]
input_type = input_node_entry["types"][input_idx[1]]
if not isinstance(input_node_entry["node"], (Var, Call)):
if not isinstance(input_node_entry["node"], (Var, Constant, Call)):
raise RuntimeError("Graph tuner can only tune target "
"operators with input node of type "
"relay.expr.Var or relay.expr.Call. Now "
"relay.expr.Var/Constant/Call. Now "
"find a target op %s with input type %s"
% (op_name, str(type(input_node_entry["node"]))))
free_var = relay.Var("var_%d" % i, input_type)
Expand Down Expand Up @@ -167,7 +167,8 @@ def _traverse_expr(node):
else:
node_entry["inputs"].append([in_node_idx, 0, 0])
elif isinstance(node, Constant):
pass
node_entry["name"] = "Constant_" + str(node_index)
node_entry["types"] = [node.checked_type]
elif isinstance(node, relay.op.op.Op):
return
else:
Expand Down
7 changes: 5 additions & 2 deletions python/tvm/autotvm/task/relay_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def _lower(mod,
grc.codegen(mod["main"])
# default case
compiler = relay.vm.VMCompiler()
compiler.set_params(params)
if params:
compiler.set_params(params)
compiler.lower(mod, target=target)


Expand Down Expand Up @@ -123,7 +124,9 @@ def extract_from_multiple_program(mods, params, ops, target, target_host=None,
# relay op -> topi compute
OP2TOPI = {
tvm.relay.op.nn.conv2d: [topi.nn.conv2d, topi.nn.depthwise_conv2d_nchw,
topi.nn.group_conv2d_nchw, topi.nn.conv2d_NCHWc],
topi.nn.group_conv2d_nchw,
topi.nn.conv2d_NCHWc,
topi.nn.conv2d_NCHWc_int8],
tvm.relay.op.nn.conv2d_transpose: [topi.nn.conv2d_transpose_nchw],
tvm.relay.op.nn.dense: [topi.nn.dense],
tvm.relay.op.nn.batch_matmul: [topi.nn.batch_matmul],
Expand Down

0 comments on commit 2d6f6a5

Please sign in to comment.