diff --git a/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp b/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp index 2712f096465c..d5c8adf35f00 100644 --- a/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp +++ b/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp @@ -2802,14 +2802,14 @@ void mlir::torch::onnx_c::populateDefaultDomainAtoF( // Get fill_value if it is present. // Assumption : resultDType and value attr type match. auto attr = binder.op->getAttr("torch.onnx.value"); - auto resultDType = resultType.getDtype(); // Extract the fill value and dtype // ONNX requires value attr to be a tensor + Value splatvalue; + // if no value attr is provided, default is 0.0 float value if (!attr) { - attr = - DenseElementsAttr::get(resultType.toBuiltinTensor(), - rewriter.getFloatAttr(resultDType, 0.0)); + splatvalue = rewriter.create( + binder.getLoc(), rewriter.getF64FloatAttr(0.0)); } // If its a dense resource attr we need to convert to a dense type: @@ -2830,19 +2830,18 @@ void mlir::torch::onnx_c::populateDefaultDomainAtoF( } Attribute splattr; - if (isa(attr)) { + if (attr && isa(attr)) { auto denseAttr = cast(attr); splattr = denseAttr.getSplatValue(); } - if (!isa(splattr)) { + if (splattr && !isa(splattr)) { return rewriter.notifyMatchFailure( binder.op, "`value` attr tensor only supports types int and float for now."); } - Value splatvalue; - if (auto intattr = dyn_cast(splattr)) { + if (auto intattr = dyn_cast_or_null(splattr)) { IntegerType intty = cast(intattr.getType()); int64_t value; if (intty.isUnsignedInteger()) { @@ -2856,7 +2855,7 @@ void mlir::torch::onnx_c::populateDefaultDomainAtoF( rewriter.create(binder.getLoc(), value); } - if (auto fpattr = dyn_cast(splattr)) + if (auto fpattr = dyn_cast_or_null(splattr)) splatvalue = rewriter.create( binder.getLoc(), rewriter.getF64FloatAttr(fpattr.getValueAsDouble())); diff --git a/projects/pt1/e2e_testing/xfail_sets.py b/projects/pt1/e2e_testing/xfail_sets.py index c79d54a80c3f..c2e126cf6050 100644 --- a/projects/pt1/e2e_testing/xfail_sets.py +++ b/projects/pt1/e2e_testing/xfail_sets.py @@ -536,12 +536,26 @@ "TensorToBool_basic", "TensorToFloatZeroRank_basic", "TensorToFloat_basic", + "TensorsSplitTensorLastSmallerModule_basic", + "TensorsSplitTensorModule_basic", + "TensorsSplitTensorNegativeDimModule_basic", "ThresholdBackward2dMixedModule_basic", "UnsafeViewCollapseDynamicWithAtenSizeIntModule_basic", "UpSampleNearest2dDynamicFactor_basic", "ViewCollapseDynamicWithAtenSizeIntModule_basic", "ViewSizeFromOtherTensor_basic", "WeightNormInterfaceModule_basic", + # Error: `aten.as_strided` op is not supported + "ChunkListUnpackDynamic_Module_basic", + "ChunkListUnpackUnevenDynamic_Module_basic", + "ChunkListUnpackUneven_Module_basic", + "ChunkListUnpack_Module_basic", + "SplitTensorGetItem_Module_basic", + "SplitTensorLastSmallerModule_basic", + "SplitTensorListUnpackModule_basic", + "SplitTensorNegativeDimModule_basic", + "SplitWithSizesListUnpackModule_basic", + "SplitWithSizes_Module_basic", } FX_IMPORTER_CRASHING_SET = LINALG_CRASHING_SET | { @@ -936,6 +950,17 @@ "UpSampleNearest2dBackward_basic", "ViewCollapseDynamicWithAtenSizeIntModule_basic", "ViewSizeFromOtherTensor_basic", + # Error: `aten.as_strided` op is not supported + "ChunkListUnpackDynamic_Module_basic", + "ChunkListUnpackUnevenDynamic_Module_basic", + "ChunkListUnpackUneven_Module_basic", + "ChunkListUnpack_Module_basic", + "SplitTensorGetItem_Module_basic", + "SplitTensorLastSmallerModule_basic", + "SplitTensorListUnpackModule_basic", + "SplitTensorNegativeDimModule_basic", + "SplitWithSizesListUnpackModule_basic", + "SplitWithSizes_Module_basic", } FX_IMPORTER_STABLEHLO_CRASHING_SET = { @@ -2503,6 +2528,20 @@ "ScaledDotProductAttentionSameModule_basic", } +if torch_version_for_comparison() > version.parse("2.6.0.dev"): + MAKE_FX_TOSA_PASS_SET = MAKE_FX_TOSA_PASS_SET - { + "ChunkListUnpackUneven_Module_basic", + "ChunkListUnpack_Module_basic", + "SplitTensorGetItem_Module_basic", + "SplitTensorLastSmallerModule_basic", + "SplitTensorListUnpackModule_basic", + "SplitTensorNegativeDimModule_basic", + "SplitWithSizesListUnpackModule_basic", + "TensorsSplitTensorLastSmallerModule_basic", + "TensorsSplitTensorModule_basic", + "TensorsSplitTensorNegativeDimModule_basic", + } + LTC_CRASHING_SET = { # TODO: update test to move all inputs to the lazy device. Otherwise test fails with: # Check failed: lazy_tensor Input tensor is not a lazy tensor: CPUBoolType. diff --git a/pytorch-hash.txt b/pytorch-hash.txt index 54a5f3e72b17..e6925022a13f 100644 --- a/pytorch-hash.txt +++ b/pytorch-hash.txt @@ -1 +1 @@ -995ec16c7adf111348db617fa59e22e7ef9d7a3c +79d8db50043ace9938cbbf4230b3515894452271 diff --git a/pytorch-requirements.txt b/pytorch-requirements.txt index a1400af6c759..7158a4c98a44 100644 --- a/pytorch-requirements.txt +++ b/pytorch-requirements.txt @@ -4,4 +4,4 @@ # release page, and we use this page as an additional source for the wheels. -f https://xilinx.github.io/torch-mlir/package-index/ --pre -torch==2.5.0.dev20240909 +torch==2.6.0.dev20240916 diff --git a/test/Conversion/TorchOnnxToTorch/simple_ops_a_to_f.mlir b/test/Conversion/TorchOnnxToTorch/simple_ops_a_to_f.mlir index 6cc0cf0ec153..d3672941acdb 100644 --- a/test/Conversion/TorchOnnxToTorch/simple_ops_a_to_f.mlir +++ b/test/Conversion/TorchOnnxToTorch/simple_ops_a_to_f.mlir @@ -2016,6 +2016,24 @@ func.func @test_flatten_1d_axis_1(%arg0: !torch.vtensor<[2],f32>) -> !torch.vten // ----- +// CHECK-LABEL: func.func @test_constant_of_shape_arg_input +func.func @test_constant_of_shape_arg_input(%arg0: !torch.vtensor<[2], si64>) -> !torch.vtensor<[?,?], f32> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 20 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} { + // CHECK: %[[INT0:.*]] = torch.constant.int 0 + // CHECK: %[[INT0_0:.*]] = torch.constant.int 0 + // CHECK: %[[EXTRACT_0:.*]] = torch.aten.select.int %arg0, %[[INT0]], %[[INT0_0]] : !torch.vtensor<[2],si64>, !torch.int, !torch.int -> !torch.vtensor<[],si64> + // CHECK: %[[ELE_0:.*]] = torch.aten.item %[[EXTRACT_0]] : !torch.vtensor<[],si64> -> !torch.int + // CHECK: %[[INT1:.*]] = torch.constant.int 1 + // CHECK: %[[EXTRACT_1:.*]] = torch.aten.select.int %arg0, %[[INT0]], %[[INT1]] : !torch.vtensor<[2],si64>, !torch.int, !torch.int -> !torch.vtensor<[],si64> + // CHECK: %[[ELE_1:.*]] = torch.aten.item %[[EXTRACT_1]] : !torch.vtensor<[],si64> -> !torch.int + // CHECK: %[[DIM_LIST:.*]] = torch.prim.ListConstruct %[[ELE_0]], %[[ELE_1]] : (!torch.int, !torch.int) -> !torch.list + // CHECK: %[[NONE:.*]] = torch.constant.none + // CHECK: %[[FILL_VAL:.*]] = torch.constant.float 0.000000e+00 + // CHECK: %[[ATEN_FULL:.*]] = torch.aten.full %[[DIM_LIST]], %[[FILL_VAL]], %[[NONE]], %[[NONE]], %[[NONE]], %[[NONE]] : !torch.list, !torch.float, !torch.none, !torch.none, !torch.none, !torch.none -> !torch.vtensor<[?,?],f32> + %0 = "torch.operator"(%arg0) <{name = "onnx.ConstantOfShape"}> : (!torch.vtensor<[2], si64>) -> !torch.vtensor<[?,?], f32> + return %0 : !torch.vtensor<[?,?], f32> +} +// ----- + // CHECK-LABEL: func.func @test_constant_of_shape_dense_float_default func.func @test_constant_of_shape_dense_float_default() -> !torch.vtensor<[2,3,4], f32> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 20 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} { // CHECK: %[[SHAPE_CST:.*]] = torch.vtensor.literal(dense<[2, 3, 4]> : tensor<3xsi64>) : !torch.vtensor<[3],si64> diff --git a/torchvision-requirements.txt b/torchvision-requirements.txt index 50a52722101c..4f831bcc3499 100644 --- a/torchvision-requirements.txt +++ b/torchvision-requirements.txt @@ -4,4 +4,4 @@ # release page, and we use this page as an additional source for the wheels. -f https://xilinx.github.io/torch-mlir/package-index/ --pre -torchvision==0.20.0.dev20240909 +torchvision==0.20.0.dev20240916