Xuxue1 opened a new issue #9237:
URL: https://github.com/apache/tvm/issues/9237
```python
class DemoModel(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, data, input_scores):
idx = input_scores > 0.7
return data[idx], input_scores[idx]
def vmobj_to_list(o, dtype="float32"):
if isinstance(o, tvm.nd.NDArray):
return [o]
elif isinstance(o, tvm.runtime.container.ADT):
result = []
for f in o:
result.extend(vmobj_to_list(f, dtype))
return result
else:
raise RuntimeError("Unknown object type: %s" % type(o))
def process_test():
device = torch.device('cuda')
model = DemoModel().to(device).eval()
input = (torch.rand(2, 3, device=device), torch.tensor([0.1, 0.5],
device=device))
traced = do_trace(model, input)
target = tvm.target.Target("cuda")
shape_list = [("input", (input[0].shape)), ("input_scores",
(input[1].shape))]
mod, params = relay.frontend.from_pytorch(traced, shape_list)
with tvm.transform.PassContext(opt_level=3):
vm_exec = relay.vm.compile(mod, target=target, params=params)
des_vm = VirtualMachine(vm_exec, tvm.cuda())
des_vm.set_input("main", input=input[0].cpu().numpy(),
input_scores=input[1].cpu().numpy())
res = vmobj_to_list(des_vm.run())
print("data: {}".format(res[0]))
print("scores: {}".format(res[1]))
if __name__ == "__main__":
process_test()
```
### Expected behavior
output: [[][]]
scores: []
### Actual behavior
output: [[0.07791223 0.7198686 0.7642788 ]
[0.07791223 0.7198686 0.7642788 ]]
scores: [0.1 0.1]
### Environment
os: ubuntu20.4 torch: 1.9.0+cu102 tvm:0.8.dev0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]