Commit 4344d4ab by Siva Committed by Tianqi Chen

[FRONTEND][TENSORFLOW] bug fix for tensorflow official slim models. (#2864)

* [FRONTEND][TENSORFLOW] bug fix for tensorflow official slim models.

* 	* review comments
parent 53e84f00
...@@ -543,25 +543,23 @@ def _reshape(): ...@@ -543,25 +543,23 @@ def _reshape():
op_name="reshape", op_name="reshape",
extras={'newshape':tuple(shape_arg.asnumpy())}, extras={'newshape':tuple(shape_arg.asnumpy())},
ignores=['Tshape'])(inputs, attr) ignores=['Tshape'])(inputs, attr)
except KeyError: except AttributeError:
# Shape operator is already pruned, hence # Shape operator is already pruned, hence
# try to infer shape by precompute prune if possible. # try to infer shape by precompute prune if possible.
if all(in_node in params for in_node in inputs[1].list_input_names()): func = _expr.Function(ir_pass.free_vars(inputs[1]), inputs[1])
func = _expr.Function(ir_pass.free_vars(inputs[1]), inputs[1]) with tvm.relay.build_config(opt_level=0):
with tvm.relay.build_config(opt_level=0): graph, lib, params = tvm.relay.build(func, target="llvm", params=params)
graph, lib, params = tvm.relay.build(func, target="llvm", params=params) ctx = tvm.context("llvm", 0)
ctx = tvm.context("llvm", 0) from tvm.contrib import graph_runtime
from tvm.contrib import graph_runtime m = graph_runtime.create(graph, lib, ctx)
m = graph_runtime.create(graph, lib, ctx) m.set_input(**params)
m.set_input(**params) m.run()
m.run() params_new = m.get_output(0)
params_new = m.get_output(0) inputs.pop(1)
inputs.pop(1) return AttrCvt(
return AttrCvt( op_name="reshape",
op_name="reshape", extras={'newshape':tuple(params_new.asnumpy().astype('int64').flatten())},
extras={'newshape':tuple(params_new.asnumpy().flatten())}, ignores=['Tshape'])(inputs, attr)
ignores=['Tshape'])(inputs, attr)
raise RuntimeError("Reshape with dynamic shape input not supported yet.")
return _impl return _impl
def _bias_add(): def _bias_add():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment