-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support native_dropout
dynamo converter
#2931
Conversation
def forward(self): | ||
return torch.ops.aten.native_dropout.default(input, p, train) | ||
|
||
inputs = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain the reason for dividing the test cases into inputs = [torch.randn(input_shape)]
and inputs = []
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If passing in inputs = [torch.randn(input_shape)]
, the input will be an ITensor. If passing the input directly into the pytorch function, the input will be a normal tensor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The code looks good to merge.
I have one more question about input types for my understanding. Usually, we handle inputs as input: TRTTensor
and only consider ITensor input. However, sometimes we use input_val: Union[TRTTensor, torch.Tensor, np.ndarray]
or input: Sequence[Union[TRTTensor, torch.Tensor, np.ndarray]]
to handle both ITensor and normal tensor types. Even though the schema doesn't show a difference, how do we distinguish between them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah very good questions.
- Even though the schema doesn't show a difference, how do we distinguish between them?
From my understanding, ITensor
is a concept in TRT so PyTorch schema doesn't distinguish them from the design perspective. (TRT is just one backend among many backends)
- Usually, we handle inputs as input: TRTTensor and only consider ITensor input. However, sometimes we use input_val: Union[TRTTensor, torch.Tensor, np.ndarray] or input: Sequence[Union[TRTTensor, torch.Tensor, np.ndarray]] to handle both ITensor and normal tensor types.
I think in the entry point the inputs are not promised to be ITensor
. Instead, they could be torch.Tensor
or np.ndarray
. So there are two ways to handle it. 1) use enforce_tensor_types
to make it as ITensor
2) manually cast it to ITensor
inside of the function. I think in most cases both are fine, but if this function is called by another function that passes in non-ITensor
, the first solution will error out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand better now. Thank you so much for the explanation!
Description
Support
native_dropout
dynamo converter.Per the schema, this function returns two tensors. The first is
output
and the other ismask
. For inference, i.e.,train
is notTrue
orNone
, whatever thep
is, it always returnsinput
and allTrue
s.Fixes #2494
Type of change
Checklist: