[JIT] Fix a bug of rejecting ops with AliasAnalysisKind::CONSERVATIVE (#64336)
authorDon Jang <djang@fb.com>
Wed, 8 Sep 2021 01:21:41 +0000 (18:21 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 8 Sep 2021 01:26:31 +0000 (18:26 -0700)
commit1a033b45dd119c7dc8856b50eb679d174ab97af3
tree52ead8eaa49f7779c470f4f2d7501a87d7d9be68
parent8e1fdd4cd3c03d452c97101900721c8d905c5339
[JIT] Fix a bug of rejecting ops with AliasAnalysisKind::CONSERVATIVE (#64336)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64336

Currently AliasDB rejects any user-defined ops with `AliasAnalysisKind::CONSERVATIVE` if they do not have a special treatment for alias analysis. For example, the following alias schema gets rejects:

```
  m.def(torch::schema(
      "namescope::my_op(...) -> ...",
      c10::AliasAnalysisKind::CONSERVATIVE));
```

This rejection condition is contradictory: AliasDB can handle ops with `CONSERVATIVE` in a general way without any special casing at https://fburl.com/diffusion/op5u72sk calling https://fburl.com/diffusion/h3aws5dd which seems very appropriate to be conservative for alias analysis.

This change corrects the rejection condition to be satisfied for ops *with* special casing but have `CONSERVATIVE`, since they both cannot be used simultaneously.

Test Plan:
Confirmed that
```
  m.def(torch::schema(
      "namescope::my_op(...) -> ...",
      c10::AliasAnalysisKind::CONSERVATIVE));
```
gets accepted and `my_op`'s all inputs and outputs are put to point to wildcard(*) by AliasDB.

Reviewed By: eellison

Differential Revision: D30690121

fbshipit-source-id: 431cc1a84edd5227f52b44a0fd85d5eb16f3c288
torch/csrc/jit/runtime/operator.cpp