diff --git a/test/dynamo_expected_failures/TestAutograd.test_gradcheck_check_no_differentiable_outputs b/test/dynamo_expected_failures/TestAutograd.test_gradcheck_check_no_differentiable_outputs deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/dynamo_expected_failures/TestExamplesCorrectnessCPU.test_maml_regression_mechanism_functional_call_cpu b/test/dynamo_expected_failures/TestExamplesCorrectnessCPU.test_maml_regression_mechanism_functional_call_cpu deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/dynamo_expected_failures/TestExamplesCorrectnessCPU.test_maml_regression_mechanism_make_functional_cpu b/test/dynamo_expected_failures/TestExamplesCorrectnessCPU.test_maml_regression_mechanism_make_functional_cpu deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/dynamo_expected_failures/TestQuantizePT2E.test_derived_qspec b/test/dynamo_expected_failures/TestQuantizePT2E.test_derived_qspec deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/dynamo_expected_failures/TestQuantizePT2EQAT_ConvBn1d.test_qat_conv_bn_bias_derived_qspec b/test/dynamo_expected_failures/TestQuantizePT2EQAT_ConvBn1d.test_qat_conv_bn_bias_derived_qspec deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/dynamo_expected_failures/TestQuantizePT2EQAT_ConvBn2d.test_qat_conv_bn_bias_derived_qspec b/test/dynamo_expected_failures/TestQuantizePT2EQAT_ConvBn2d.test_qat_conv_bn_bias_derived_qspec deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/dynamo_expected_failures/TestTensorCreationCPU.test_cartesian_prod_cpu b/test/dynamo_expected_failures/TestTensorCreationCPU.test_cartesian_prod_cpu deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/torch/_refs/__init__.py b/torch/_refs/__init__.py index 818c195fceb..fa571489bd7 100644 --- a/torch/_refs/__init__.py +++ b/torch/_refs/__init__.py @@ -6332,21 +6332,15 @@ def _infer_scalar_type(obj): # Analogous to recursive_store # xref: recursive_store in torch/csrc/utils/tensor_new.cpp -def _recursive_build(sizes, dim, scalarType, obj): - ndim = len(sizes) - assert dim <= ndim - if dim == ndim: +def _recursive_build(scalarType: torch.dtype, obj: TensorOrNumberLikeType): + if isinstance(obj, Tensor) and obj.ndim <= 1: + obj = obj.item() + # fall through into next case + if isinstance(obj, Number): return torch.scalar_tensor(obj, dtype=scalarType) - n = sizes[dim] + seq = obj - seq_size = len(seq) - if seq_size != n: - raise ValueError( - f"expected sequence of length {n} at dim {dim} (got {seq_size})" - ) - return torch.stack( - [_recursive_build(sizes, dim + 1, scalarType, item) for item in seq] - ) + return torch.stack([_recursive_build(scalarType, item) for item in seq]) # xref: internal_new_from_data in torch/csrc/utils/tensor_new.cpp @@ -6383,7 +6377,6 @@ def _internal_new_from_data( # TODO: test for numpy input with PyArray_Check device = device_opt if device_opt is not None else options["device"] - sizes = _compute_sizes(data, scalar_type) inferred_scalar_type = _infer_scalar_type(data) if type_inference else scalar_type # NB: Don't need to avoid tracing, as we aren't going to do any manual @@ -6398,7 +6391,7 @@ def _internal_new_from_data( # of a freshly allocated CPU tensor. Here, we're going to do an # alternate, heinously slow implementation: turn each individual # scalar into a tensor, and then repeatedly cat them together - tensor = _recursive_build(sizes, 0, inferred_scalar_type, data) + tensor = _recursive_build(inferred_scalar_type, data) tensor = tensor.to(device, inferred_scalar_type, non_blocking=False, copy=False)