-
Notifications
You must be signed in to change notification settings - Fork 1
Update evaluate.py to be able to profile and correctly validate the outputs on VM #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: echuraev/virtual_device
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about that. Why we should infer the network one more time for getting outputs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these spaces
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it work? It looks like method Validate takes only 2 arguments but you pass 3...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.