Hi folks,

I'm trying to use `DFPatternRewriteComposer` defined in 
`src/relay/transforms/simplify_expr.h` to compose rewrite patterns.  
Suppose some of my rewrite patterns get arguments in constructor like this,
```c++
class SimplifyXXX : public DFPatternRewrite {
  public:
    SimplifyXXX(size_t batch_size_): batch_size(batch_size_) {
      ...
    }
  ...
  private:
    size_t batch_size;
    ...
}
```
and I tried to add this pattern in composer like this,
```c++
size_t batch_size = 1;
DFPatternRewriteComposer composer;
composer.AddRewrite<SimplifyXXX, size_t>(batch_size);
```
then it results in compile error as follows.
```bash
[build] /root/tvm/src/relay/transforms/simplify_expr.h:72:55: error: invalid 
conversion from 'long unsigned int*' to 'long unsigned int' [-fpermissive]
[build]    72 |     rewrites_.push_back(std::make_shared<T, Args...>(&args...));
[build]       |                                                       ^~~~
[build]       |                                                       |
[build]       |                                                       long 
unsigned int*
```

So I tried to change the code in `src/relay/transforms/simplify_expr.h:72` like 
below and there was no error. (Note that `&` was moved from `args` to `Args`)
```c++
rewrites_.push_back(std::make_shared<T, Args&...>(args...));
```

I'm quite new to tvm and modern C++, so I'm not sure whether my change is 
correct. Could you give any opinions about this?

Thanks!





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/dfpatternrewritecomposer-addrewrite-with-additional-args-raises-compile-error/12323/1)
 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/eb4da767f7c745c32051944c50001f74baf97cd17a54aa91aba3ef32f75181db).

Reply via email to