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
18 changes: 12 additions & 6 deletions test/test_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3705,8 +3705,9 @@ def foobar(xyz):
scripted = torch.jit.script(foobar)

_, lineno = inspect.getsourcelines(foobar)
FileCheck().check('test_jit.py:{}:20'.format(lineno + 1))\
.run(scripted.graph)
fc = FileCheck().check('test_jit.py:{}:20'.format(lineno + 1))
fc.run(scripted.graph)
fc.run(str(scripted.graph))

def test_file_line_save_load(self):
class Scripted(torch.jit.ScriptModule):
Expand All @@ -3723,15 +3724,19 @@ def forward(self, xyz):
bytesio = io.BytesIO(buffer)
scripted = torch.jit.load(bytesio)

FileCheck().check('code/archive.py:4:10').run(scripted.graph)
fc = FileCheck().check('code/archive.py:4:10')
fc.run(scripted.graph)
fc.run(str(scripted.graph))

def test_file_line_string(self):
scripted = torch.jit.CompilationUnit('''
def foo(xyz):
return torch.neg(xyz)
''')

FileCheck().check('<string>:2:12').run(scripted.foo.graph)
fc = FileCheck().check('<string>:2:12')
fc.run(scripted.foo.graph)
fc.run(str(scripted.foo.graph))

def test_file_line_trace(self):
def foobar(xyz):
Expand All @@ -3740,8 +3745,9 @@ def foobar(xyz):
scripted = torch.jit.trace(foobar, (torch.rand(3, 4)))

_, lineno = inspect.getsourcelines(foobar)
FileCheck().check('test_jit.py:{}:0'.format(lineno + 1))\
.run(scripted.graph)
fc = FileCheck().check('test_jit.py:{}:0'.format(lineno + 1))
fc.run(scripted.graph)
fc.run(str(scripted.graph))

def test_tensor_shape(self):
x = torch.empty(34, 56, 78)
Expand Down
2 changes: 1 addition & 1 deletion torch/csrc/jit/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ struct Graph {

TORCH_API ~Graph();

TORCH_API std::string toString(bool print_source_locations=false) const;
TORCH_API std::string toString(bool print_source_locations = true) const;

TORCH_API std::ostream& print(
std::ostream& out,
Expand Down