fPecc commented on issue #11558:
URL: https://github.com/apache/tvm/issues/11558#issuecomment-1148412516
After some more analysis, I was able to build using the AOT executor with
the following code:
```
from tvm.relay.op.vision import non_max_suppression
from tvm import te
import numpy as np
from tvm import topi
import tvm
from tvm import relay
# An example to use non_max_suppression
x0 = relay.var("x0", relay.ty.TensorType((1, 100, 6), "float32"))
x1 = relay.var("x1", relay.ty.TensorType((1,), "int32"))
x2 = relay.var("x2", relay.ty.TensorType((1, 100), "int32"))
x3 = relay.var("x3", relay.ty.TensorType((), "int32"))
z = relay.vision.non_max_suppression(
x0,
x1,
x2,
x3,
iou_threshold=0.5,
force_suppress=True,
top_k=2,
return_indices=True,
invalid_to_bottom=False,
)
z = z.astuple()
func = relay.Function([x0, x1, x2, x3], z)
mod = tvm.IRModule()
mod["main"] = func
print(mod["main"])
RUNTIME = tvm.relay.backend.Runtime("crt", {"system-lib": True})
TARGET = tvm.target.target.Target({"kind": "c"})
EXECUTOR = tvm.relay.backend.Executor("aot",options={'interface-api':
'c','unpacked-api': 1, 'link-params': True})
mod = relay.build(mod, executor=EXECUTOR, target=TARGET,runtime=RUNTIME)
print(mod)
```
I was able to build it after modifying method GetNewArguments in file
src/relay/transforms/fuse_ops.cc.
Previous code:
```
...
if (!link_params_ || new_arg.as<ConstantNode>() == nullptr) {
Var param = ginfo_[current_group].GetOrAllocParam(new_arg, type);
new_args.push_back(param);
} else {
new_args.push_back(new_arg);
}
...
```
Modified code:
```
...
if (!link_params_ || new_arg.as<ConstantNode>() == nullptr) {
Var param = ginfo_[current_group].GetOrAllocParam(new_arg, type);
new_args.push_back(param);
} else {
Var param = ginfo_[current_group].GetOrAllocParam(new_arg, type);
new_args.push_back(param);
}
...
```
I would like to understand why is there a distinction in the GetNewArguments
method, that pushes different args into new_args. I am not sure if I found a
bug, or if there is some other previous error (perhaps in the definition of
non_max_suppression).
--
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]