Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Jun 16, 2019

Stack from ghstack:

We don't support this yet, so it should error clearly.

Differential Revision: D15857568

We don't support this yet, so it should error clearly.
@pytorchbot pytorchbot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jun 16, 2019
@suo suo requested review from Krovatkin and zdevito June 16, 2019 22:16
[jit] improve error message on recursive class defs

We don't support this yet, so it should error clearly.

gh-metadata: pytorch pytorch 21842 gh/suo/63/head
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.

Yeah, good idea.

test/test_jit.py Outdated
"""
Recursive class types not yet supported. We should give a good error message.
"""
with self.assertRaisesRegex(RuntimeError, "Recursive class attributes not yet supported"):
Copy link
Contributor

Choose a reason for hiding this comment

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

"Recursive class" is a bit vague as a concept can it be made more clear what is being objected to here?

// Recursively check contained types. We need to do this because a user may do
// A -> B -> A.
for (const auto& type : attrType->containedTypes()) {
if (isRecursive(classType, type)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The naive search here seems like it could get really inefficient with any complicated hierarchies

Copy link
Member Author

Choose a reason for hiding this comment

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

BFS would be faster given how types are structured. But like, how complicated are we talking lol—this search is linear in the size of the type DAG, so unless someone is making 100000-nested compound types I think we're ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we're doing a second traversal if it's a tuple type, so if we have deep nested tuples we may need to add manually unrolling.

Copy link
Contributor

@eellison eellison Jun 17, 2019

Choose a reason for hiding this comment

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

I think this is exponential in the worst case... Edit: nvm not exponential i think it's n^3

Copy link
Contributor

Choose a reason for hiding this comment

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

If you have N numbered nodes where each node is connected to all nodes with a lower number

[jit] improve error message on recursive class defs

We don't support this yet, so it should error clearly.

gh-metadata: pytorch pytorch 21842 gh/suo/63/head
Copy link
Contributor

@Krovatkin Krovatkin left a comment

Choose a reason for hiding this comment

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

:shipit:

suo added 2 commits June 17, 2019 11:43
[jit] improve error message on recursive class defs

We don't support this yet, so it should error clearly.

gh-metadata: pytorch pytorch 21842 gh/suo/63/head
[jit] improve error message on recursive class defs

We don't support this yet, so it should error clearly.

gh-metadata: pytorch pytorch 21842 gh/suo/63/head
@zou3519 zou3519 deleted the gh/suo/63/head branch June 17, 2019 22:26
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in d329dff.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants