2020-07-07 07:28:26 +08:00
|
|
|
// RUN: mlir-hlo-opt %s -inline | FileCheck %s
|
|
|
|
|
2020-07-07 12:51:24 +08:00
|
|
|
// Test case: Basic test of inlining into mhlo.while.
|
2020-07-07 07:28:26 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: func @caller
|
2020-07-07 12:51:24 +08:00
|
|
|
// CHECK: "mhlo.while"{{.*}}( {
|
2020-07-07 07:28:26 +08:00
|
|
|
// CHECK: }, {
|
2020-07-07 12:51:24 +08:00
|
|
|
// CHECK: "mhlo.exponential"
|
2020-07-07 07:28:26 +08:00
|
|
|
// CHECK: })
|
|
|
|
// CHECK-LABEL: func @callee
|
|
|
|
|
|
|
|
func @caller(%arg0: tensor<f32>, %pred: tensor<i1>) -> tensor<f32> {
|
2020-07-07 12:51:24 +08:00
|
|
|
%0 = "mhlo.while"(%arg0) ( {
|
2020-07-07 07:28:26 +08:00
|
|
|
^entry(%unused: tensor<f32>):
|
2020-07-07 12:51:24 +08:00
|
|
|
"mhlo.return"(%pred) : (tensor<i1>) -> ()
|
2020-07-07 07:28:26 +08:00
|
|
|
}, {
|
|
|
|
^entry(%0: tensor<f32>):
|
|
|
|
%1 = call @callee(%0) : (tensor<f32>) -> (tensor<f32>)
|
2020-07-07 12:51:24 +08:00
|
|
|
"mhlo.return"(%1) : (tensor<f32>) -> ()
|
2020-07-07 07:28:26 +08:00
|
|
|
} ) : (tensor<f32>) -> (tensor<f32>)
|
|
|
|
return %0 : tensor<f32>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func @callee(%arg0: tensor<f32>) -> tensor<f32> {
|
2020-07-07 12:51:24 +08:00
|
|
|
%0 = "mhlo.exponential"(%arg0) : (tensor<f32>) -> tensor<f32>
|
2020-07-07 07:28:26 +08:00
|
|
|
return %0 : tensor<f32>
|
|
|
|
}
|