pytorch/torch/nn
Shen Li f5d18574a3 Allow Module forward-pre and forward hooks to take kwargs (#89389)
closes #35643

This PR is mostly borrowed from #82042. Thanks @Padarn for implementing
the first version and debugging into the errors.

Based on the discussion in #82042 this PR adds a with_kwargs
argument to register_forward_pre_hook and register_forward_hook
methods. When the arg is set to true, the provided hook must accept
kwargs args. Under the hook, this PR adds a
`_forward_pre_hooks_with_kwargs` and a `_forward_hook_with_kwargs`
set to keep track of which hooks accept kwargs.

Differential Revision: [D41431111](https://our.internmc.facebook.com/intern/diff/D41431111)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/89389
Approved by: https://github.com/soulitzer
2022-11-23 02:43:32 +00:00
..
backends
intrinsic [quant][ao_migration] nn.intrinsic.quantized migration to ao (#86172) 2022-10-08 00:01:38 +00:00
modules Allow Module forward-pre and forward hooks to take kwargs (#89389) 2022-11-23 02:43:32 +00:00
parallel [DDP][Docs] Add warning that no_sync() should include forward (#89244) 2022-11-18 22:06:24 +00:00
qat [quant] Subpackage import in nn.quantized (#84141) 2022-09-01 11:35:03 +00:00
quantizable [quant][ao_migration] torch.nn.quantizabletorch.ao.nn.quantizable. (#78717) 2022-08-25 16:50:37 +00:00
quantized Rename 'torch/ao/nn/quantized._reference' to 'torch/ao/nn/quantized/reference'. (#84974) 2022-09-16 17:49:07 +00:00
utils Fix typos in messages under torch (#89049) 2022-11-17 04:18:14 +00:00
__init__.py Properly import Parameter and DataParallel in torch/nn/__init__.py (#80955) 2022-07-06 20:49:44 +00:00
_reduction.py
common_types.py
cpp.py
functional.py Fix torch.nn.functional.gelu docstring formatting (#89061) 2022-11-18 01:57:41 +00:00
functional.pyi.in Add Dropout1d module 2022-06-15 14:39:07 +00:00
grad.py Integrate xdoctest - Rebased (#82797) 2022-08-12 02:08:01 +00:00
init.py More doctest refinements. (#83317) 2022-08-22 20:07:26 +00:00
parameter.py [fix] allow saving python attr on Tensor and Parameter via torch.save (#81616) 2022-11-11 21:11:12 +00:00
parameter.pyi