Skip to content

Commit

Permalink
[meta_tensor] polish error strings in meta registrations (#95052)
Browse files Browse the repository at this point in the history
I found some error message should be formatted for detailed information. So I polished those error message.
Pull Request resolved: pytorch/pytorch#95052
Approved by: https://github.com/bdhirsh
  • Loading branch information
1SAA authored and cyyever committed Mar 27, 2023
1 parent ddaa32c commit ad49b3f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions torch/_meta_registrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ def common_meta_baddbmm_bmm(batch1, batch2, is_bmm, self_baddbmm=None):
check(self_baddbmm.dim() == 3, lambda: "self must be a 3D tensor")
check(
self_baddbmm.size() == output_size,
lambda: "Expected an input tensor shape with shape {output_size} but got shape: {self.size()}",
lambda: f"Expected an input tensor shape with shape {output_size} but got shape: {self_baddbmm.size()}",
)

return output
Expand Down Expand Up @@ -1665,7 +1665,7 @@ def meta_max_pool2d_with_indices_backward(

check(
self.dtype == grad_output.dtype,
lambda: "expected dtype {self.dtype} for `gradOutput` but got dtype {grad_output.dtype}",
lambda: f"Expected dtype {self.dtype} for `gradOutput` but got dtype {grad_output.dtype}",
)

nOutputPlane = nInputPlane
Expand Down Expand Up @@ -2278,7 +2278,7 @@ def upsample_common_check(input_size, output_size, num_spatial_dims):
def upsample_nearest1d(input, output_size, scales=None):
check(
input.numel() != 0 or multiply_integers(input.size()[1:]),
lambda: "Non-empty 3D data tensor expected but got a tensor with sizes {input.size()}",
lambda: f"Non-empty 3D data tensor expected but got a tensor with sizes {input.size()}",
)
full_output_size = upsample_common_check(
input.size(), output_size, num_spatial_dims=1
Expand All @@ -2292,7 +2292,7 @@ def upsample_nearest1d(input, output_size, scales=None):
def upsample_nearest2d(input, output_size, scales_h=None, scales_w=None):
check(
input.numel() != 0 or multiply_integers(input.size()[1:]),
lambda: "Non-empty 4D data tensor expected but got a tensor with sizes {input.size()}",
lambda: f"Non-empty 4D data tensor expected but got a tensor with sizes {input.size()}",
)
full_output_size = upsample_common_check(
input.size(), output_size, num_spatial_dims=2
Expand All @@ -2316,7 +2316,7 @@ def upsample_nearest2d(input, output_size, scales_h=None, scales_w=None):
def upsample_nearest3d(input, output_size, scales_d=None, scales_h=None, scales_w=None):
check(
input.numel() != 0 or multiply_integers(input.size()[1:]),
lambda: "Non-empty 5D data tensor expected but got a tensor with sizes {input.size()}",
lambda: f"Non-empty 5D data tensor expected but got a tensor with sizes {input.size()}",
)
full_output_size = upsample_common_check(
input.size(), output_size, num_spatial_dims=3
Expand Down

0 comments on commit ad49b3f

Please sign in to comment.