Skip to content

Conversation

@driazati
Copy link
Contributor

@driazati driazati commented Jul 18, 2019

The type hint was being ignored when emitting None constants, this also de-dups some testing code

Differential Revision: D16364572

@pytorchbot pytorchbot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jul 18, 2019
@driazati driazati requested a review from jamesr66a July 18, 2019 18:41
Copy link
Collaborator

@jamesr66a jamesr66a left a comment

Choose a reason for hiding this comment

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

Looks OK but I had some questions

@driazati driazati requested a review from jamesr66a July 18, 2019 20:14
Copy link
Collaborator

@jamesr66a jamesr66a left a comment

Choose a reason for hiding this comment

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

now we are on horse

n->output()->setType(result_type);
} else {
// Implicitly wrap non-optionals
n->output()->setType(OptionalType::create(result_type));
Copy link
Contributor

Choose a reason for hiding this comment

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

How can this branch ever be reached ? inferred_type->isSubtypeOf(NoneType::get()) && !inferred_type->isSubtypeOf(result_type)) means that result_type has to be an Optional.

Copy link
Contributor Author

@driazati driazati Jul 19, 2019

Choose a reason for hiding this comment

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

This is in there to maintain compatibility for calls like torch.jit.annotate(Tensor, None) where the type hint is Tensor

Copy link
Contributor

@eellison eellison Jul 19, 2019

Choose a reason for hiding this comment

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

I think this should be handled in the compiler and not here. InsertConstant is a common API and this usage would be a bug at any of the other callsites

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a bug though, it's something we support currently. Plus keeping it here lets us have all usages in 1 place so we can more easily delete it later if we go that route

Copy link
Contributor

@eellison eellison Jul 22, 2019

Choose a reason for hiding this comment

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

It is a bug. In any other case having a type of Tensor for a value of None is a bug

@facebook-github-bot
Copy link
Contributor

@driazati merged this pull request in fad3031.

@driazati driazati closed this Jul 24, 2019
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.

7 participants