forked from OSchip/llvm-project
Move non-spec TOSA operators into TosaUtilOps.td
Reviewed By: stellaraccident Differential Revision: https://reviews.llvm.org/D99628
This commit is contained in:
parent
fcf6800506
commit
888c5067b4
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue