Skip to content

Commit d22e82a

Browse files
author
Meghan Lele
committed
Update on "[JIT] Add property support for ScriptModules"
**Summary** This commit extends support for properties to include ScriptModules. **Test Plan** This commit adds a unit test that has a ScriptModule with a user-defined property. `python test/test_jit_py3.py TestScriptPy3.test_module_properties` Differential Revision: [D22880298](https://our.internmc.facebook.com/intern/diff/D22880298) [ghstack-poisoned]
2 parents 2bb610e + b7631ac commit d22e82a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torch/jit/_recursive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def init_fn(script_module):
433433
# Add the methods to the script_module directly. This ensures they will
434434
# be found first when `name` is looked up (as opposed to the stubs or
435435
# nn.Module.forward)
436-
script_module.__dict__[name] = wrapped_script_method # type: ignore
436+
script_module.__dict__[name] = wrapped_script_method
437437

438438

439439
# Make module properties available on the Python ScriptModule class.
@@ -443,7 +443,7 @@ def init_fn(script_module):
443443
# Setter is optional, so it may not exist.
444444
setter_name = property_stub.def_.setter_name()
445445
fset = cpp_module._get_method(setter_name.name) if setter_name else None
446-
script_module.__dict__[property_name] = property(property_name, fget, fset)
446+
script_module.__dict__[property_name] = property(property_name, fget, fset) # type: ignore
447447

448448
# copy over python methods to script module if they aren't defined on the script module
449449
# this is currently an internal api used only on module containers

0 commit comments

Comments
 (0)