blob: 5bfd4e477c21c8953798010cc208a5487af81663 [file] [log] [blame]
// RUN: mlir-opt -split-input-file -convert-math-to-spirv -verify-diagnostics %s -o - | FileCheck %s
module attributes { spv.target_env = #spv.target_env<#spv.vce<v1.0, [Kernel], []>, {}> } {
// CHECK-LABEL: @float32_unary_scalar
func @float32_unary_scalar(%arg0: f32) {
// CHECK: spv.OCL.cos %{{.*}}: f32
%0 = math.cos %arg0 : f32
// CHECK: spv.OCL.exp %{{.*}}: f32
%1 = math.exp %arg0 : f32
// CHECK: spv.OCL.log %{{.*}}: f32
%2 = math.log %arg0 : f32
// CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32
// CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}}
// CHECK: spv.OCL.log %[[ADDONE]]
%3 = math.log1p %arg0 : f32
// CHECK: spv.OCL.rsqrt %{{.*}}: f32
%4 = math.rsqrt %arg0 : f32
// CHECK: spv.OCL.sqrt %{{.*}}: f32
%5 = math.sqrt %arg0 : f32
// CHECK: spv.OCL.tanh %{{.*}}: f32
%6 = math.tanh %arg0 : f32
// CHECK: spv.OCL.sin %{{.*}}: f32
%7 = math.sin %arg0 : f32
// CHECK: spv.OCL.fabs %{{.*}}: f32
%8 = math.abs %arg0 : f32
// CHECK: spv.OCL.ceil %{{.*}}: f32
%9 = math.ceil %arg0 : f32
// CHECK: spv.OCL.floor %{{.*}}: f32
%10 = math.floor %arg0 : f32
return
}
// CHECK-LABEL: @float32_unary_vector
func @float32_unary_vector(%arg0: vector<3xf32>) {
// CHECK: spv.OCL.cos %{{.*}}: vector<3xf32>
%0 = math.cos %arg0 : vector<3xf32>
// CHECK: spv.OCL.exp %{{.*}}: vector<3xf32>
%1 = math.exp %arg0 : vector<3xf32>
// CHECK: spv.OCL.log %{{.*}}: vector<3xf32>
%2 = math.log %arg0 : vector<3xf32>
// CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<3xf32>
// CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}}
// CHECK: spv.OCL.log %[[ADDONE]]
%3 = math.log1p %arg0 : vector<3xf32>
// CHECK: spv.OCL.rsqrt %{{.*}}: vector<3xf32>
%4 = math.rsqrt %arg0 : vector<3xf32>
// CHECK: spv.OCL.sqrt %{{.*}}: vector<3xf32>
%5 = math.sqrt %arg0 : vector<3xf32>
// CHECK: spv.OCL.tanh %{{.*}}: vector<3xf32>
%6 = math.tanh %arg0 : vector<3xf32>
// CHECK: spv.OCL.sin %{{.*}}: vector<3xf32>
%7 = math.sin %arg0 : vector<3xf32>
return
}
// CHECK-LABEL: @float32_binary_scalar
func @float32_binary_scalar(%lhs: f32, %rhs: f32) {
// CHECK: spv.OCL.pow %{{.*}}: f32
%0 = math.powf %lhs, %rhs : f32
return
}
// CHECK-LABEL: @float32_binary_vector
func @float32_binary_vector(%lhs: vector<4xf32>, %rhs: vector<4xf32>) {
// CHECK: spv.OCL.pow %{{.*}}: vector<4xf32>
%0 = math.powf %lhs, %rhs : vector<4xf32>
return
}
} // end module