Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/test_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12692,6 +12692,13 @@ def test_python_op_name(self):
def fn():
return random.randint()

def test_dir(self):
class M(torch.jit.ScriptModule):
def forward(self, t):
return t

self.assertTrue('forward' in dir(M()))

def test_inferred_error_msg(self):
"""
Test that when we get a type mismatch on a function where we inferred
Expand Down
2 changes: 1 addition & 1 deletion torch/jit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ def conv_module_to_const(module_value):
super(ScriptModule, self).__setattr__(attr, _get_valid_constant(attr, value))

def __dir__(self):
return sorted(Module.__dir__(self) + self._method_names())
return sorted(Module.__dir__(self) + self._c._method_names())

def define(self, lang):
# We use frames_up=1 to get to the proper surrounding scope. The stack
Expand Down