-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
Description
When lowering to the EmitC dialect, MLIR inserts a builtin.unrealized_conversion_cast to connect types that do not have a direct conversion.
In this case, the lowering produces a cast from !emitc.ptr to !emitc.array<...xf32>.
When trying to emit C++ code, the CppEmitter fails
ERROR :
error: 'builtin.unrealized_conversion_cast' op unable to find printer for op
%9 = builtin.unrealized_conversion_cast %8 :
!emitc.ptr to !emitc.array<1x3x4x4xf32>
Input :
module {
func.func @main(%arg0: tensor<1x3x4x4xf32>, %arg1: tensor<1x3x4x4xf32>)
-> tensor<1x3x4x4xf32> {
%3 = "tosa.add"(%arg0, %arg1)
: (tensor<1x3x4x4xf32>, tensor<1x3x4x4xf32>)
-> tensor<1x3x4x4xf32>
%4 = "tosa.sub"(%3, %arg1)
: (tensor<1x3x4x4xf32>, tensor<1x3x4x4xf32>)
-> tensor<1x3x4x4xf32>
return %4 : tensor<1x3x4x4xf32>
}
}
Run With :
mlir-opt input.mlir -pass-pipeline="builtin.module(
func.func(tosa-to-linalg),
one-shot-bufferize{bufferize-function-boundaries function-boundary-type-conversion=identity-layout-map buffer-alignment=0},
buffer-results-to-out-params{hoist-static-allocs=true},
func.func(convert-linalg-to-loops),
canonicalize,
convert-to-emitc
)" -o output.mlir
PRODUCED EMITC IR :
Steps to reproduce
Save the input MLIR program above.
Run the pipeline shown.
Attempt to translate the resulting EmitC IR to C++.
Observe that printing fails on the unrealized_conversion_cast.