Skip to content

Conversation

@AmosLewis
Copy link
Collaborator

@AmosLewis AmosLewis commented Jan 17, 2025

To test llvm/torch-mlir#3963

construct_inputs.log
Failed test at stage construct_inputs with exception:
Numpy doesn't support bfloat16. Please consider modifying the boundary types.

But if it pass manually run

iree-run-module --device=local-task --module=compiled_model.vmfb --function=main --input="1xbf16=1.0"
EXEC @main
result[0]: hal.buffer_view
1xf16=1
module {
  func.func @main(%arg0: !torch.vtensor<[1],bf16>) -> !torch.vtensor<[1],f16> attributes {torch.onnx_meta.ir_version = 10 : si64, torch.onnx_meta.opset_version = 21 : si64, torch.onnx_meta.producer_name = "", torch.onnx_meta.producer_version = ""} {
    %none = torch.constant.none
    %0 = torch.operator "onnx.Cast"(%arg0) {torch.onnx.to = 10 : si64} : (!torch.vtensor<[1],bf16>) -> !torch.vtensor<[1],f16> 
    return %0 : !torch.vtensor<[1],f16>
  }
}
#map = affine_map<(d0) -> (0)>
#map1 = affine_map<(d0) -> (d0)>
module {
  func.func @main(%arg0: tensor<1xbf16>) -> tensor<1xf16> {
    %0 = tensor.empty() : tensor<1xf16>
    %1 = linalg.generic {indexing_maps = [#map, #map1], iterator_types = ["parallel"]} ins(%arg0 : tensor<1xbf16>) outs(%0 : tensor<1xf16>) {
    ^bb0(%in: bf16, %out: f16):
      %2 = arith.extf %in : bf16 to f32
      %3 = arith.truncf %2 : f32 to f16
      linalg.yield %3 : f16
    } -> tensor<1xf16>
    return %1 : tensor<1xf16>
  }
}

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.

1 participant