File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
torchvision/transforms/v2/functional Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -179,9 +179,10 @@ def _xyxy_to_xywh(xyxy: torch.Tensor, inplace: bool) -> torch.Tensor:
179179def _cxcywh_to_xyxy (cxcywh : torch .Tensor , inplace : bool ) -> torch .Tensor :
180180 # For integer tensors, use float arithmetic to match the behavior of
181181 # `torchvision.ops._box_convert._box_cxcywh_to_xyxy`.
182+ original = cxcywh
182183 dtype = cxcywh .dtype
183184 need_cast = not cxcywh .is_floating_point ()
184- # Float conversion creates a copy, so we only need to clone for floating point when not inplace
185+
185186 if need_cast :
186187 cxcywh = cxcywh .float ()
187188 elif not inplace :
@@ -195,6 +196,9 @@ def _cxcywh_to_xyxy(cxcywh: torch.Tensor, inplace: bool) -> torch.Tensor:
195196
196197 if need_cast :
197198 cxcywh = cxcywh .to (dtype )
199+ if inplace :
200+ original [:] = cxcywh
201+ return original
198202
199203 return cxcywh
200204
You can’t perform that action at this time.
0 commit comments