[Mlir-commits] [mlir] 888c506 - Move non-spec TOSA operators into TosaUtilOps.td

Rob Suderman llvmlistbot at llvm.org
Wed Mar 31 11:09:28 PDT 2021


Author: Suraj Sudhir
Date: 2021-03-31T11:01:01-07:00
New Revision: 888c5067b4dce403774536a08f79d59865db3d12

URL: https://github.com/llvm/llvm-project/commit/888c5067b4dce403774536a08f79d59865db3d12
DIFF: https://github.com/llvm/llvm-project/commit/888c5067b4dce403774536a08f79d59865db3d12.diff

LOG: Move non-spec TOSA operators into TosaUtilOps.td

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D99628

Added: 
    mlir/include/mlir/Dialect/Tosa/IR/TosaUtilOps.td

Modified: 
    mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index 75a2926f4a103..43138f1e8707c 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -6,7 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file defines the operation set for the TOSA dialect.
+// This file defines the operation set for the TOSA dialect as defined in
+// the TOSA specfication (https://developer.mlplatform.org/w/tosa/). 
 //
 //===----------------------------------------------------------------------===//
 
@@ -1517,30 +1518,6 @@ def Tosa_RescaleOp: Tosa_Op<"rescale", [NoSideEffect]> {
   );
 }
 
-def Tosa_ApplyScaleOp: Tosa_Op<"apply_scale", [NoSideEffect] # ElementwiseMappable.traits> {
-  let summary = "Rescale scalar operator for Tosa tensor operators";
-
-  let description = [{
-    Applies rescaling for fixed point values. This behavior is replicated in
-    multiple quantized operations (mul, convolution, rescale, matmul, pooling).
-
-    The commonplace implementation is to use i64 operations to avoid integer
-    overflow with target specific implementations can use native operations to
-    avoid wider than necessary types.
-  }];
-
-  let arguments = (ins
-    Tosa_Int32Like:$value,
-    Tosa_Int32Like:$multiplier,
-    Tosa_Int8Like:$shift,
-    BoolAttr:$double_round
-  );
-
-  let results = (outs
-    Tosa_Int32:$output
-  );
-}
-
 //===----------------------------------------------------------------------===//
 // TOSA Spec Section 2.13
 // Operator Class: Data Node Ops.
@@ -1727,23 +1704,6 @@ def Tosa_WhileOp : Tosa_Op<"while_loop", [
   );
 }
 
-//===----------------------------------------------------------------------===//
-// Operator: yield
-//===----------------------------------------------------------------------===//
-def Tosa_YieldOp : Tosa_Op<"yield", [
-       Terminator,
-       NoSideEffect]> {
-  let summary = "yield operator";
-
-  let description = [{
-    return operation within the conditional and body of
-    structured control flow. Operation takes variadic operands
-    but produces no results of its own.
-  }];
-
-  let arguments = (ins
-    Variadic<Tosa_Tensor>:$inputs
-  );
-}
+include "mlir/Dialect/Tosa/IR/TosaUtilOps.td"
 
 #endif // TOSA_OPS

diff  --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaUtilOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaUtilOps.td
new file mode 100644
index 0000000000000..f1dfb78d9a727
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaUtilOps.td
@@ -0,0 +1,70 @@
+//===-- TosaUtilOps.td - TOSA dialect utility operations ---*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines codegen utility operators for the TOSA dialect. 
+// These operators are not part of the formal TOSA specification and 
+// are intended to aid code generation from TOSA. 
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TOSA_UTIL_OPS
+#define TOSA_UTIL_OPS
+
+include "mlir/IR/OpBase.td"
+
+include "mlir/Interfaces/SideEffectInterfaces.td"
+include "mlir/Interfaces/LoopLikeInterface.td"
+include "mlir/Dialect/Tosa/IR/TosaInterfaces.td"
+
+include "mlir/Dialect/Tosa/IR/TosaTypesBase.td"
+include "mlir/Dialect/Tosa/IR/TosaOpBase.td"
+
+def Tosa_ApplyScaleOp: Tosa_Op<"apply_scale", [NoSideEffect] # ElementwiseMappable.traits> {
+  let summary = "Rescale scalar operator for Tosa tensor operators";
+
+  let description = [{
+    Applies rescaling for fixed point values. This behavior is replicated in
+    multiple quantized operations (mul, convolution, rescale, matmul, pooling).
+
+    The commonplace implementation is to use i64 operations to avoid integer
+    overflow with target specific implementations can use native operations to
+    avoid wider than necessary types.
+  }];
+
+  let arguments = (ins
+    Tosa_Int32Like:$value,
+    Tosa_Int32Like:$multiplier,
+    Tosa_Int8Like:$shift,
+    BoolAttr:$double_round
+  );
+
+  let results = (outs
+    Tosa_Int32:$output
+  );
+}
+
+//===----------------------------------------------------------------------===//
+// Operator: yield
+//===----------------------------------------------------------------------===//
+def Tosa_YieldOp : Tosa_Op<"yield", [
+       Terminator,
+       NoSideEffect]> {
+  let summary = "yield operator";
+
+  let description = [{
+    return operation within the conditional and body of
+    structured control flow. Operation takes variadic operands
+    but produces no results of its own.
+  }];
+
+  let arguments = (ins
+    Variadic<Tosa_Tensor>:$inputs
+  );
+}
+
+#endif // TOSA_UTIL_OPS


        


More information about the Mlir-commits mailing list