Repository navigation
Enable lowering for upsample_bilinear2d with scale factor - #4464
Conversation
| @@ -2905,16 +2905,16 @@ at::Tensor XLANativeFunctions::upsample_bilinear2d( | |||
|
c10::optional |
|||
| TORCH_LAZY_FN_COUNTER("xla::"); | |||
| XLATensorPtr self_tensor = bridge::GetXlaTensor(self); | |||
There was a problem hiding this comment.
I think we need to make sure only one of (scales_h + scales_w ) and output_size is specified, otherwise I don't know which one we should believe. Ideally upsteram already does that check but we can make it more explict.
There was a problem hiding this comment.
After investigating using GDB, I found the output_size will always be filled by upstream (at: https://github.com/pytorch/pytorch/blob/88366a907549abdd7e2c402a961b60c2be910824/aten/src/ATen/native/UpSampleBilinear2d.cpp#L166)
With the current upstream implementation, we can rely on the output_size inferred from scales_h/w by upstream. However, I think we can keep the scale factor shape inference here to make it future-proof.
In the scale factor shape inference block, I think we can do a shape validation if output_size is not empty, to make sure the output shape and the inferred shape are the same.
|
For a sanity check, @lsy323 can you check if you use python api |
Will do, thanks! |
Tested with the following Python script, |
* Enable lowering for upsample_bilinear2d with scale factor * fix linter * add shape validation
* Enable lowering for upsample_bilinear2d with scale factor * fix linter * add shape validation
This fixes #2703
Enable lowering for upsample_bilinear2d with scale factor
Added a new unit tests of upsample_bilinear2d with scale factor != 1. The test will fail with the current implementation, since it will fallback to Aten with scale factor != 1. The test passed after the lowering for upsample_bilinear2d with scale factor is supported.