[PATCH] D79102: [mlir] Add sine operation to Standard dialect.
Mahesh Ravishankar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 10:11:24 PDT 2020
mravishankar created this revision.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, bader, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: antiagainst.
Herald added a project: LLVM.
mravishankar added reviewers: mehdi_amini, rriddle.
Also add lowering of sine operation to SPIR-V dialect.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79102
Files:
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
mlir/test/IR/core-ops.mlir
Index: mlir/test/IR/core-ops.mlir
===================================================================
--- mlir/test/IR/core-ops.mlir
+++ mlir/test/IR/core-ops.mlir
@@ -515,6 +515,18 @@
// CHECK: %{{[0-9]+}} = rsqrt %arg1 : f32
%145 = rsqrt %f : f32
+ // CHECK: %{{[0-9]+}} = sin %arg1 : f32
+ %146 = "std.sin"(%f) : (f32) -> f32
+
+ // CHECK: %{{[0-9]+}} = sin %arg1 : f32
+ %147 = sin %f : f32
+
+ // CHECK: %{{[0-9]+}} = sin %cst_8 : vector<4xf32>
+ %148 = sin %vcf32 : vector<4xf32>
+
+ // CHECK: %{{[0-9]+}} = sin %arg0 : tensor<4x4x?xf32>
+ %149 = sin %t : tensor<4x4x?xf32>
+
return
}
Index: mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
===================================================================
--- mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
+++ mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
@@ -52,6 +52,8 @@
%7 = sqrt %arg0 : f32
// CHECK: spv.GLSL.Tanh %{{.*}}: f32
%8 = tanh %arg0 : f32
+ // CHECK: spv.GLSL.Sin %{{.*}}: f32
+ %9 = sin %arg0 : f32
return
}
Index: mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
===================================================================
--- mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -590,6 +590,7 @@
UnaryAndBinaryOpPattern<SignedRemIOp, spirv::SRemOp>,
UnaryAndBinaryOpPattern<SignedShiftRightOp,
spirv::ShiftRightArithmeticOp>,
+ UnaryAndBinaryOpPattern<SinOp, spirv::GLSLSinOp>,
UnaryAndBinaryOpPattern<SqrtOp, spirv::GLSLSqrtOp>,
UnaryAndBinaryOpPattern<SubFOp, spirv::FSubOp>,
UnaryAndBinaryOpPattern<SubIOp, spirv::ISubOp>,
Index: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
===================================================================
--- mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -1246,6 +1246,36 @@
}];
}
+def SinOp : FloatUnaryOp<"sin"> {
+ let summary = "sine of the specified value";
+ let description = [{
+ Syntax:
+
+ ```
+ operation ::= ssa-id `=` `std.sin` ssa-use `:` type
+ ```
+
+ The `sin` operation computes the sine of a given value. It takes one
+ operand and returns one result of the same type. This type may be a float
+ scalar type, a vector whose element type is float, or a tensor of floats.
+ It has no standard attributes.
+
+ Example:
+
+ ```mlir
+ // Scalar sine value.
+ %a = sin %b : f64
+
+ // SIMD vector element-wise sine value.
+ %f = sin %g : vector<4xf32>
+
+ // Tensor element-wise sine value.
+ %x = sin %y : tensor<4x?xf8>
+ ```
+ }];
+}
+
+
//===----------------------------------------------------------------------===//
// DeallocOp
//===----------------------------------------------------------------------===//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79102.260948.patch
Type: text/x-patch
Size: 2919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/3389ec9c/attachment.bin>
More information about the llvm-commits
mailing list