MergeComposite pass doesn't aware of the constant index. In general, this is 
not managed by most of transform passes because it's not necessary. It's fine 
as long as we could find the right constant via its index in run time.

You could have two options:

1. Include constants in the composite functions (the current approach). In this 
option, you have to manage the constants in your codegen.
2. Exclude constants in the composite function (use `wildcard`). In this 
option, all constants become composite function arguments, and you don't need 
to worry about the constant index, because the JSON runtime will provide you 
the right input/output tensors (whatever they are coming from user input or 
constants).

Your JSON runtime should look like (ref: 
https://github.com/apache/tvm/blob/main/src/runtime/contrib/dnnl/dnnl_json_runtime.cc#L64):

```
  void Run() override {
    for (size_t i = 0; i < input_nodes_.size(); ++i) {
      // Preprocess the input buffers.
     inputs[i] = ...;
    }

    // Invoke the engine.
    run_kernel(inputs, outputs);
  }
```





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/byoc-why-constant-index-changes-after-mergecomposite-pass/11744/2)
 to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.apache.org/email/unsubscribe/f4d43ded31be64bad337e8093b8c68e07c70d6637a34b4d44dca43f3bea97006).

Reply via email to