Skip to content

Conversation

zezhang
Copy link
Contributor

@zezhang zezhang commented Jun 6, 2025

  • Remove StableHLO dependency
  • Apply patches to build torch-mlir without stablehlo and stablehlo lit tests
  • Update APIs realted to isa<>, cast<>, and dyn_cast<>
  • Add a new EliminateUnusedTorchOpsPass to remove unused torch ops in torch-to-tcp (see example below):
module {
  func.func @func_main(%arg0: !torch.vtensor<[?,3],f32>, %arg1: !torch.vtensor<[?,3],f32>) -> !torch.vtensor<[?,3],f32> {
    %int2 = torch.constant.int 2
    %int0 = torch.constant.int 0
    %0 = torch.symbolic_int "s35" {min_val = 0, max_val = 9223372036854775807} : !torch.int
    torch.bind_symbolic_shape %arg0, [%0], affine_map<()[s0] -> (s0, 3)> : !torch.vtensor<[?,3],f32>
    torch.bind_symbolic_shape %arg1, [%0], affine_map<()[s0] -> (s0, 3)> : !torch.vtensor<[?,3],f32>
    %1 = torch.aten.size.int %arg0, %int0 : !torch.vtensor<[?,3],f32>, !torch.int -> !torch.int
    %2 = torch.aten.size.int %arg1, %int0 : !torch.vtensor<[?,3],f32>, !torch.int -> !torch.int
    %3 = torch.aten.sub.Tensor %arg0, %arg1, %int2 : !torch.vtensor<[?,3],f32>, !torch.vtensor<[?,3],f32>, !torch.int -> !torch.vtensor<[?,3],f32>
    torch.bind_symbolic_shape %3, [%0], affine_map<()[s0] -> (s0, 3)> : !torch.vtensor<[?,3],f32>
    %4 = torch.aten.eq.int %1, %2 : !torch.int, !torch.int -> !torch.bool
    %5 = torch.aten.Int.bool %4 : !torch.bool -> !torch.int
    %6 = torch.aten.Bool.int %5 : !torch.int -> !torch.bool
    torch.runtime.assert %6, "Runtime assertion failed for expression Eq(s35, s58) on node 'eq_2'"
    return %3 : !torch.vtensor<[?,3],f32>
  }
}

where the torch.runtime.assert and related checking ops can be removed.

@zezhang zezhang changed the title Zezhang/upgrade jun 05 LLVM / Torch-Mlir Upgrade Jun 10, 2025
@zezhang zezhang marked this pull request as ready for review June 10, 2025 15:28
@zezhang zezhang merged commit da237d0 into llvm:main Jun 10, 2025
2 of 3 checks passed
@zezhang zezhang deleted the zezhang/upgrade_jun_05 branch June 10, 2025 16:14
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.

2 participants