Skip to content

Conversation

@dsbarinov1
Copy link

No description provided.

@dsbarinov1 dsbarinov1 changed the base branch from main to echuraev/virtual_device July 21, 2023 09:19
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)
Copy link
Owner

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?

Copy link
Author

@dsbarinov1 dsbarinov1 Jul 21, 2023

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
Comment on lines 1468 to 1469

print("Benchmark GraphExecutor")
Copy link
Owner

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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Benchmark Virtual Machine")
from tvm.runtime import profiler_vm

evaluate.py Outdated
Comment on lines 28 to 29
from tvm.runtime import profiler_vm

Copy link
Owner

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)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant change

Copy link
Owner

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)
Copy link
Owner

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...

Copy link
Author

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.

@dsbarinov1 dsbarinov1 force-pushed the dbarinov/virtual_device branch from 48f4ee9 to e9d2468 Compare July 21, 2023 10:11
echuraev pushed a commit that referenced this pull request Aug 9, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants