mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-04 03:44:59 +00:00
92a836da07
This allows for inferring the result types of operations in certain situations by using the type of an operand. This commit allowed for automatically supporting type inference for many more operations with no additional effort, e.g. nearly all Arithmetic operations now support result type inferrence with no additional changes. Differential Revision: https://reviews.llvm.org/D124581
27 lines
1009 B
MLIR
27 lines
1009 B
MLIR
// RUN: mlir-opt %s --test-shape-function-report -verify-diagnostics
|
|
|
|
module attributes {shape.lib = [@shape_lib]} {
|
|
|
|
// expected-remark@+1 {{associated shape function: same_result_shape}}
|
|
func.func @tanh(%arg: tensor<10x20xf32>) -> tensor<10x20xf32>
|
|
attributes {shape.function = @shape_lib::@same_result_shape} {
|
|
// expected-remark@+1 {{implements InferType op interface}}
|
|
%0 = math.tanh %arg : tensor<10x20xf32>
|
|
// expected-remark@+1 {{implements InferType op interface}}
|
|
%1 = "test.same_operand_result_type"(%0) : (tensor<10x20xf32>) -> tensor<10x20xf32>
|
|
return %1 : tensor<10x20xf32>
|
|
}
|
|
|
|
// The shape function library with some local functions.
|
|
shape.function_library @shape_lib {
|
|
// Test shape function that returns the shape of input arg as result shape.
|
|
func @same_result_shape(%arg: !shape.value_shape) -> !shape.shape {
|
|
%0 = shape_of %arg : !shape.value_shape -> !shape.shape
|
|
return %0 : !shape.shape
|
|
}
|
|
} mapping {
|
|
test.same_operand_result_type = @same_result_shape
|
|
}
|
|
|
|
}
|