Hey @eric-haibin-lin, Thank you for the valuable examples!

I was thinking if we can further alleviate frontend developers' burden in 
writing operators with side effects. For example, frontend developers are only 
required to produce the program like below:

```
fn @just_a_dropout(%x) {
  let %y = _stateful_dropout(%x);
  %y
}
```

and then we provide a pass to replace `_stateful_dropout` properly:

```
fn @just_a_dropout(%x) {
  let %prng = RefRead(%global_var_prng_ref);
  let (%y, %new_prng) = dropout(%x, %prng);
  RefWrite(%global_var_prng_ref, %new_prng);
  %y
}
```

Note that this approach requires that we ignore potential dependency issues. 
For example, imagine if there are two parallel dropouts with no dependency 
between each other, then this approach would add an arbitrary dependency. 
However, in our case of neural networks, it doesn't really matter.





---
[Visit 
Topic](https://discuss.tvm.ai/t/rfc-handling-effect-in-tvm-and-relay/5946/23) 
to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.ai/email/unsubscribe/01481a25eb4b210debf64b95d47a8ece0e5a0edbfc6201b43d81d7787f817a3e).

Reply via email to