Skip to content

Conversation

@jamesr66a
Copy link
Collaborator

@jamesr66a jamesr66a commented May 24, 2019

Resolves https://github.com/pytorch/lockdown/issues/29

Examples:

import torch

@torch.jit.script
def foobar(x):
    return torch.blargh(xyz)

==

RuntimeError: 
object has no attribute blargh:
at compile.py:5:12
@torch.jit.script
def foo(x):
    return torch.blargh(x)
           ~~~~~~~~~~~~ <--- HERE

It also gets the correct column number in the case where the original source file has common leading whitespace in front of the callable:

import torch

with torch.no_grad():
            @torch.jit.script
            def foo(x):
                return torch.blargh(x)

==
RuntimeError: 
object has no attribute blargh:
at compile_leading.py:6:24
@torch.jit.script
def foo(x):
    return torch.blargh(x)
           ~~~~~~~~~~~~ <--- HERE

@jamesr66a jamesr66a requested review from suo and zdevito May 24, 2019 03:56
@pytorchbot pytorchbot added oncall: jit Add this issue/PR to JIT oncall triage queue module: pybind Related to our Python bindings / interactions with other Python libraries labels May 24, 2019
@jamesr66a jamesr66a changed the title [JIT] Record source/line info in SourceRange and report in highlight + graph [JIT] Record source/line info in SourceRange and report in highlight May 24, 2019
suo
suo previously requested changes May 24, 2019
Copy link
Member

@suo suo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our dreams are coming true

@jamesr66a jamesr66a force-pushed the file_line branch 2 times, most recently from 6ffe317 to ea201db Compare May 24, 2019 20:41
@jamesr66a jamesr66a requested review from suo and zdevito May 24, 2019 21:05
Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few inline comments where there may be bugs but it generally looks good.

}
}

std::tuple<size_t, size_t> line_col_to_byte_offs(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is python frontend specific so it should probably live in SourceRangeFactory not here.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesr66a is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jamesr66a merged this pull request in 6875018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: pybind Related to our Python bindings / interactions with other Python libraries oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants