torch-mlir/test/Conversion
Ashay Rane 21f070e95f
onnx: fix checks in TorchOnnxToTorch pass to match the ONNX spec (#2848)
This PR contains three commits to update the validation checks in the
ONNX -> Torch conversion pass for the AveragePool, Pad, and Slice operators:

> onnx: fix preconditions for lowering AveragePool ops
> 
> The `pads` attribute of the AveragePool operator specifies the value to
> pad at both the beginning as well as the end of the axis (see
> https://onnx.ai/onnx/operators/onnx__AveragePool.html#attributes), so
> the size of this attribute should be twice the rank of the input tensor.
> However, our TorchOnnxToTorch bails out early since it incorrectly
> compares the pads attribute with the rank (not twice the rank) of the
> input tensor.
> 
> This patch fixes the code to match the spec and adds a lit test.

> onnx: allow optional constant value for Pad operator
> 
> The `constant_value` input of the onnx.Pad operator is optional (see
> https://onnx.ai/onnx/operators/onnx__Pad.html#inputs), but the
existing
> logic for lowering the operator into the Torch dialect assumes that it
> is mandatory.
> 
> This patch makes the attribute optional and constructs a default value
> (a list of zeros the size of the input tensor) if the attribute was not
> specified.

> onnx: fix checks for axes and steps inputs of Slice operator
> 
> The ONNX Spec for the Slice operator allows the `starts` and `ends`
> inputs to have fewer indices that the dimensions of the `data` tensor
> (see https://onnx.ai/onnx/operators/onnx__Slice.html), but our code
> expects these inputs to be as many as the `data` tensor's dimensions.
> 
> More precisely, the spec requires that the `starts` and `ends` inputs
> are only as long as the `axes` input, but since the `axes` input is
> optional, the default type for the `axes` input has to match the type
> for the `starts` and `ends` inputs. Moreover, the number of indices in
> the `steps` input also has to match those in the `axes` inputs (instad
> of matching the dimensions of the `data` input).
> 
> This patch fixes the checks in the TorchOnnxToTorch conversion so that
> they match the ONNX spec.
2024-02-07 21:19:27 -08:00
..
TorchConversionToMLProgram Bump LLVM and StableHLO (#2598) 2023-11-28 22:12:24 -08:00
TorchOnnxToTorch onnx: fix checks in TorchOnnxToTorch pass to match the ONNX spec (#2848) 2024-02-07 21:19:27 -08:00
TorchToArith [Torch Dialect] add folder for aten.any.bool (#2388) 2023-08-30 17:29:03 +08:00
TorchToLinalg [torch-mlir][sparse] preserve sparsity during lowering torch to linalg (#2809) 2024-01-26 10:54:59 -08:00
TorchToSCF mlir: bump llvm tag to 5380e3 (#856) 2022-05-16 12:54:35 -07:00
TorchToStablehlo Bump stablehlo to openxla/stablehlo@fd52182f76 (#2821) 2024-01-31 14:21:17 -08:00
TorchToTensor [onnx] Lowering for `onnx.shape` to `torch` and `tensor` (#2648) 2023-12-15 11:37:49 -08:00
TorchToTosa [torch-mlir][conversion-test] cleanup trailing whitespace in mlir files (#2807) 2024-01-25 14:24:28 -08:00