@@ -69,7 +69,7 @@ Tensor sum_batching_rule(const Tensor& self, OptionalIntArrayRef opt_dims, bool
69
69
// >>> x = torch.randn(B0) # the per-examples are all scalars
70
70
// >>> vmap(partial(torch.sum, dim=0), x)
71
71
// then we replicate the behavior of sum(scalar_tensor, dim=0).
72
- if (/* logical*/ self.dim () == 0 && (dims.size () == 0 || (dims.size () == 1 && is_allowed_dim_on_scalar_tensor (dims[0 ])))) {
72
+ if (/* logical*/ self.dim () == 0 && (dims.empty () || (dims.size () == 1 && is_allowed_dim_on_scalar_tensor (dims[0 ])))) {
73
73
return self.clone ();
74
74
}
75
75
}
@@ -477,7 +477,7 @@ Tensor view_batching_rule(const Tensor& self, IntArrayRef size) {
477
477
Tensor view_as_complex_batching_rule (const Tensor& self) {
478
478
// guard against the user passing in a batch of scalar tensors with batch
479
479
// size equal to 2.
480
- TORCH_CHECK (self.sizes ().size () != 0 , " Input tensor must have one or more dimensions" );
480
+ TORCH_CHECK (! self.sizes ().empty () , " Input tensor must have one or more dimensions" );
481
481
auto self_physical = MultiBatchVmapTransform::logicalToPhysical (self);
482
482
auto result = at::view_as_complex (self_physical.tensor ());
483
483
return self_physical.getPhysicalToLogicalMap ().apply (result);
@@ -931,7 +931,7 @@ Tensor cat_batching_rule(const ITensorListRef& tensors, int64_t dim) {
931
931
auto physical_tensors = fmap (
932
932
physical_views, [](const VmapPhysicalView& view) -> Tensor { return view.tensor (); });
933
933
TORCH_INTERNAL_ASSERT (
934
- tensors.size () > 0 , " The dispatcher should not have dispatched here otherwise." );
934
+ ! tensors.empty () , " The dispatcher should not have dispatched here otherwise." );
935
935
auto result = at::cat (physical_tensors, physical_views[0 ].getPhysicalDim (dim));
936
936
return physical_views[0 ].getPhysicalToLogicalMap ().apply (result);
937
937
}
@@ -941,7 +941,7 @@ Tensor stack_batching_rule(TensorList tensors, int64_t dim) {
941
941
auto physical_tensors = fmap (
942
942
physical_views, [](const VmapPhysicalView& view) -> Tensor { return view.tensor (); });
943
943
TORCH_INTERNAL_ASSERT (
944
- tensors.size () > 0 , " The dispatcher should not have dispatched here otherwise." );
944
+ ! tensors.empty () , " The dispatcher should not have dispatched here otherwise." );
945
945
// NB: stack wraps the dimensionality to (logical dim + 1), so we have to
946
946
// manually handle that here.
947
947
auto dim_physical =
0 commit comments