Skip to content

Conversation

@ZolotukhinM
Copy link

It might need some cleaning up and might be missing some features, but it should be already working for most cases.

This PR is based on top of PR16986 (so please review only the last commit here).

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Feb 12, 2019
Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

Looks good!! Main comment is about when to parse the type of values. Block inputs should probably be added on this PR.

Follow-up PRs can handle more complex type parsing, and differentiable subgraphs / fusion groups.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use AT_ASSERT instead ? abort isn't really used as a pattern and AT_ASSERT will give line number information / derive from common exception class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding this type parser gives us a different type parser in type_parser.cpp, operator.cpp, annotations.py, and now irparser.cpp 🤪

I'm not sure if any of them can be unified but worth keeping track of...

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I'll take a look at those parser and see what can be shared.

Copy link
Contributor

@eellison eellison Feb 13, 2019

Choose a reason for hiding this comment

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

I don't think it's possible currently, since we have types internally that are not user-exposed - CompleteTensorType, for example.

Maybe in the future if we expose annotating detailed Tensor Types than it might work. But as of now I'm not sure that much can be shared.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should not end up with a fourth type parser. I think it would be best to share the schema parser's std::pair<TypePtr, c10::optional<AliasInfo>> parseType(), which can be refactored to be a common component. It is the closest in syntax to what the IR printer prints, and we can add cases for DimensionedTensor and CompleteTensor that are feature-gated by a boolean. For now this code is fine, as long as the followup that merges it happens.

Copy link
Contributor

Choose a reason for hiding this comment

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

This will fail with something like:

%7 : float = prim::Constant[value=2]()

I would imagine you want to change the way float attributes are printed in ir.cpp to do something similar to what is done here

case IValue::Tag::Double: {

Copy link
Contributor

Choose a reason for hiding this comment

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

I think to parse attribute you need the type annotation of the node. Otherwise there's no way to determine the attribute type of empty lists. This will also make it easier to parse floats...

Copy link
Author

Choose a reason for hiding this comment

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

We probably can add optional annotation into IR to resolve these ambiguities, e.g.
%x : float = my::node[value=10 : float, someList=[] : string[]]()

Also, please note that the lists support is pretty limited in the parser at the moment, and that's something I plan to work on incrementally after this initial big diff lands.

Copy link
Contributor

Choose a reason for hiding this comment

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

Simplest thing would be to use the attributes suffix on each token: 10i, []is

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea maybe add an assertion that the name is contained, I think it should fail here

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need the block name, fyi

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe parse operator name / op name? that's how it's referred to in the rest of the codebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

I imagine we always want to have a block here. If you're inside a graph use g->block().

Copy link
Contributor

Choose a reason for hiding this comment

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

Stmt inputs won't have their type annotated, we just want to parse the value name and access the value in our map. See my comment at parseBlockOutputs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Return statements won't have the type annotated

@zdevito
Copy link
Contributor

zdevito commented Feb 13, 2019

Currently this is based on another commit but it has multiple commits itself, so there is no way to comment on just these changes. Can it be rebased so that there is only one commit with the changes for this PR?

@ezyang
Copy link
Contributor

ezyang commented Feb 13, 2019

@ZolotukhinM I have a tool which can "stack" diffs appropriately, as zdevito is requesting, at https://github.com/ezyang/gh Let me know if you're interested in beta testing it.

@ZolotukhinM
Copy link
Author

Thanks @ezyang, I'll try to use it next time (this time the first PR has already landed).

@zdevito, the PR should now only contain IR-parser bits. Please take a look!

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.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

This looks good. I only have minor things.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably don't need no type, can't it just be "Tensor" (based on usage in this file)

Copy link
Contributor

Choose a reason for hiding this comment

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

We should not end up with a fourth type parser. I think it would be best to share the schema parser's std::pair<TypePtr, c10::optional<AliasInfo>> parseType(), which can be refactored to be a common component. It is the closest in syntax to what the IR printer prints, and we can add cases for DimensionedTensor and CompleteTensor that are feature-gated by a boolean. For now this code is fine, as long as the followup that merges it happens.

Copy link
Contributor

Choose a reason for hiding this comment

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

All the errors should use throw ErrorReport(token.range()) << "..." that way the error is reported with the right source information.

Copy link
Contributor

Choose a reason for hiding this comment

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

Symbol::attr(name) does the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

these probably should be int64_t

Copy link
Contributor

Choose a reason for hiding this comment

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

Simplest thing would be to use the attributes suffix on each token: 10i, []is

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This code appears twice, refactor?

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.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Mikhail Zolotukhin added 3 commits February 16, 2019 17:45
It might need some cleaning up and might be missing some features, but it should
be already working for most cases.
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.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants