Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoBump] Merge with fixes of 50f71030 (Jun 04) (61) #298

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

jorickert
Copy link

No description provided.

qingyunqu and others added 2 commits June 4, 2024 09:04
Support lowering unsigned integer type to stablehlo as discussed in
llvm#2184.

The things I do in this PR:
1. create `setupBackendTypeConversionForStablehlo()`,
`createFuncBackendTypeConversionForStablehloPass` and
`createFinalizingBackendTypeConversionForStablehloPass`.
2. remove `InferTypeOpInterface` from `torch_c.to_builtin_tensor`,
because it's different result type between linalg backend and stablehlo
backend:
```
// linalg backend
func.func @forward(%arg0: !torch.vtensor<[3],ui8>) -> tensor<3xf32> {
    %c = torch_c.to_builtin_tensor %arg0 : (!torch.vtensor<[3], ui8> -> tensor<3xi8>
    %0 = tensor.empty() : tensor<3xf32>
    %1 = linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel"]} ins(%arg0 : tensor<3xi8>) outs(%0 : tensor<3xf32>) {
    ^bb0(%in: i8, %out: f32):
      %2 = arith.uitofp %in : i8 to f32
      linalg.yield %2 : f32
    } -> tensor<3xf32>
    return %1 : tensor<3xf32>
}
// stablehlo backend
func.func @forward(%arg0: !torch.vtensor<[3],ui8>) -> tensor<3xf32> {
    %c = torch_c.to_builtin_tensor %arg0 : (!torch.vtensor<[3], ui8> -> tensor<3xui8>
    %0 = stablehlo.convert %arg0 : (tensor<3xui8> -> tensor<3xf32>
    return %0 : tensor<3xf32>
}
```
3. fix stablehlo and linalg's conversion
@jorickert jorickert marked this pull request as draft September 6, 2024 13:43
@jorickert
Copy link
Author

jorickert commented Sep 6, 2024

TODO: This fails to compile downstream with

In file included from ../third-party/llvm-project/mlir/include/mlir/IR/PatternMatch.h:12:
../third-party/llvm-project/mlir/include/mlir/IR/Builders.h:511:11: error: no matching member function for call to 'build'
  511 |     OpTy::build(*this, state, std::forward<Args>(args)...);
      |     ~~~~~~^~~~~
  290 |       return builder.create<TorchConversion::ToBuiltinTensorOp>(loc, inputs[0]);
      |                      ^
third-party/llvm-project/tools/torch-mlir/include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionOps.h.inc:1171:15: note: candidate function not viable: requires 4 arguments, but 3 were provided
 1171 |   static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand);
      |               ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
third-party/llvm-project/tools/torch-mlir/include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionOps.h.inc:1172:15: note: candidate function not viable: requires 4 arguments, but 3 were provided
 1172 |   static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand);
      |               ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
third-party/llvm-project/tools/torch-mlir/include/torch-mlir/Dialect/TorchConversion/IR/TorchConversionOps.h.inc:1173:15: note: candidate function not viable: requires at least 4 arguments, but 3 were provided
 1173 |   static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
      |               ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@mgehre-amd mgehre-amd marked this pull request as ready for review September 9, 2024 11:55
@mgehre-amd
Copy link
Collaborator

Looks to me as relatively easy to fix downstream

Base automatically changed from bump_to_56d21cba to feature/backport_ea1_ops September 11, 2024 12:08
@mgehre-amd mgehre-amd merged commit 7c5a142 into feature/backport_ea1_ops Sep 11, 2024
4 checks passed
@mgehre-amd mgehre-amd deleted the bump_to_50f71030 branch September 11, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants