pytorch
3552be10 - [jit] fix the NoneType param/buffer hack (#32745)

Commit
4 years ago
[jit] fix the NoneType param/buffer hack (#32745) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/32745 Some parameters (like `bias` in conv) are optional. To achieve this previously, you had to add `bias` as a constant, which would invoke some pretty weird behavior in the frontend, summarized as: ``` if bias is not None: add it as a parameter normally else: # bias is None add it as a constant with the value None ``` There are several things bad about this: 1. Bias is not a constant. Marking it `__constants__` is confusing. 2. It basically relies on an implementation detail (the frontend processes parameters before constants) to work. Okay, whatever. I don't even know why we did this originally, but getting rid of it doesn't break anything, so I assume improved NoneType refinement has made this a non-issue. Note on perf: this will make no difference; if bias was `None` it's still folded out today, if bias is a Tensor it would be added as a parameter both before and after this change Test Plan: Imported from OSS Differential Revision: D19628634 Pulled By: suo fbshipit-source-id: d9128a09c5d096b938fcf567b8c23b09ac9ab37f
Author
suo suo
Parents
Loading