Update evaluate.py to be able to profile and correctly validate the outputs on VM#1
Conversation
| def Validate(self, m, ref_outputs=[]): | ||
| if isinstance(m, tvm.runtime.vm.VirtualMachine) or isinstance(m, tvm.runtime.profiler_vm.VirtualMachineProfiler): | ||
| tvm_output = m.get_outputs()[0] | ||
| tvm_output = m.invoke("main", **data) |
There was a problem hiding this comment.
I'm confused about that. Why we should infer the network one more time for getting outputs?
There was a problem hiding this comment.
I believe that is because we run "invoke_stateful" before, which "Invoke a function and ignore the returned result." (CC from tvm/python/tvm/runtime/vm.py#invoke_stateful). Besides that, m.get_outputs() should do the work, but for some reason it is not returning correct outputs.
evaluate.py
Outdated
|
|
||
| print("Benchmark GraphExecutor") |
There was a problem hiding this comment.
Redundant change. Please, remove it.
evaluate.py
Outdated
| # from tvm.contrib import graph_executor | ||
| from tvm.runtime.vm import VirtualMachine | ||
|
|
||
| print("Benchmark Virtual Machine") |
There was a problem hiding this comment.
| print("Benchmark Virtual Machine") | |
| from tvm.runtime import profiler_vm |
evaluate.py
Outdated
| from tvm.runtime import profiler_vm | ||
|
|
There was a problem hiding this comment.
Suggest to move it below. See comment with suggestion.
| data = tvm.nd.array(np.random.normal(size=input_shape).astype("float32"), ctx) | ||
| vm.set_input("main", data) | ||
|
|
||
| if isinstance(validator, Validator): | ||
| ref_outputs = validator.GetReference() | ||
| validator.Validate(vm, ref_outputs) | ||
| validator.Validate(vm, ref_outputs, data) |
There was a problem hiding this comment.
How does it work? It looks like method Validate takes only 2 arguments but you pass 3...
There was a problem hiding this comment.
For some reason the corresponding change in Validate was not in commit. Should be fine now.
48f4ee9 to
e9d2468
Compare
…pache#15483) * [Script] Be more careful when generating ast.ExtSlice for Subscript The ast.ExtSlice expects a non-empty list, otherwise evaluation fails with "error: empty dims on ExtSlice". Also, each element in "dims" list of ExtSlice must be either Slice or Index. In python3.8 an expression A[()] is parsed (by ast) as Subscript with slice being Index(value=Tuple(elts=[])). When we translate a subscript from doc.AST to ast, we unconditionally convert every tuple to ast.ExtSlice, which in this case is incorrect. The fix is to map empty tuple back to the Index(Tuple[])) instead of ExtSlice. In other cases, ensure that members of ExtSlice are of correct types. * Fix lint #1
No description provided.