From 581fb5d0e706d8669dd5ce21e1be2770b4951e02 Mon Sep 17 00:00:00 2001 From: Tai Ly Date: Thu, 16 Feb 2023 22:57:53 +0000 Subject: Add Tosa Deserialization Signed-off-by: Tai Ly Change-Id: I8b0220a8465e75b1accf6b0854e911a425730da6 --- include/DeserializationPasses.h | 37 ++++++++++++++++ include/DeserializationPasses.td | 25 +++++++++++ include/schema_operator.def | 93 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 include/DeserializationPasses.h create mode 100644 include/DeserializationPasses.td create mode 100644 include/schema_operator.def (limited to 'include') diff --git a/include/DeserializationPasses.h b/include/DeserializationPasses.h new file mode 100644 index 0000000..1bc195a --- /dev/null +++ b/include/DeserializationPasses.h @@ -0,0 +1,37 @@ + +// Copyright (c) 2023, ARM Limited. +// +// Licensed under the Apache License, Version 2.0 with LLVM Exceptions +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://llvm.org/LICENSE.txt +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef INCLUDE_DESERIALIZATION_PASSES_H +#define INCLUDE_DESERIALIZATION_PASSES_H + +#include + +#include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project +#include "mlir/Pass/Pass.h" // from @llvm-project + +namespace mlir { +namespace tosa { + +std::unique_ptr createTosaDeserializePass(); +std::unique_ptr createTosaDeserializeJSONPass(); + +#define GEN_PASS_REGISTRATION +#define GEN_PASS_CLASSES +#include "include/DeserializationPasses.h.inc" + +} // namespace tosa +} // namespace mlir + +#endif // INCLUDE_DESERIALIZATION_PASSES_H diff --git a/include/DeserializationPasses.td b/include/DeserializationPasses.td new file mode 100644 index 0000000..999f0b4 --- /dev/null +++ b/include/DeserializationPasses.td @@ -0,0 +1,25 @@ +// Copyright (c) 2023, ARM Limited. +// +// Licensed under the Apache License, Version 2.0 with LLVM Exceptions +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://llvm.org/LICENSE.txt +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +include "mlir/Pass/PassBase.td" + +def TosaDeserializationPass : Pass<"tosa-deserialize", "func::FuncOp"> { + let summary = "Deserialize TOSA flatbuffer. Clear original MLIR graph and generate TOSA MLIR"; + let constructor = "createTosaDeserializePass()"; +} + +def TosaDeserializationJSONPass : Pass<"tosa-deserialize-json", "func::FuncOp"> { + let summary = "Deserialize TOSA flatbuffer JSON form. Clear original MLIR graph and generate TOSA MLIR"; + let constructor = "createTosaDeserializeJSONPass()"; +} diff --git a/include/schema_operator.def b/include/schema_operator.def new file mode 100644 index 0000000..1af367e --- /dev/null +++ b/include/schema_operator.def @@ -0,0 +1,93 @@ +// Copyright (c) 2023, ARM Limited. +// +// Licensed under the Apache License, Version 2.0 with LLVM Exceptions +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://llvm.org/LICENSE.txt +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* + Syntax: + DEF_SCHEMA_OPERATOR(SCHEMA_OP_NAME) + + Description: + SCHEMA_OP_NAME: the schema operator names, must match Op names in schema/tosa.fbs in serialization_lib repo +*/ + +/* schema operators */ +DEF_SCHEMA_OPERATOR(ARGMAX) +DEF_SCHEMA_OPERATOR(AVG_POOL2D) +DEF_SCHEMA_OPERATOR(CONV2D) +DEF_SCHEMA_OPERATOR(CONV3D) +DEF_SCHEMA_OPERATOR(DEPTHWISE_CONV2D) +DEF_SCHEMA_OPERATOR(FULLY_CONNECTED) +DEF_SCHEMA_OPERATOR(MATMUL) +DEF_SCHEMA_OPERATOR(MAX_POOL2D) +DEF_SCHEMA_OPERATOR(TRANSPOSE_CONV2D) +DEF_SCHEMA_OPERATOR(CLAMP) +DEF_SCHEMA_OPERATOR(RESERVED) +DEF_SCHEMA_OPERATOR(SIGMOID) +DEF_SCHEMA_OPERATOR(TANH) +DEF_SCHEMA_OPERATOR(ADD) +DEF_SCHEMA_OPERATOR(ARITHMETIC_RIGHT_SHIFT) +DEF_SCHEMA_OPERATOR(BITWISE_AND) +DEF_SCHEMA_OPERATOR(BITWISE_OR) +DEF_SCHEMA_OPERATOR(BITWISE_XOR) +DEF_SCHEMA_OPERATOR(INTDIV) +DEF_SCHEMA_OPERATOR(LOGICAL_AND) +DEF_SCHEMA_OPERATOR(LOGICAL_LEFT_SHIFT) +DEF_SCHEMA_OPERATOR(LOGICAL_RIGHT_SHIFT) +DEF_SCHEMA_OPERATOR(LOGICAL_OR) +DEF_SCHEMA_OPERATOR(LOGICAL_XOR) +DEF_SCHEMA_OPERATOR(MAXIMUM) +DEF_SCHEMA_OPERATOR(MINIMUM) +DEF_SCHEMA_OPERATOR(MUL) +DEF_SCHEMA_OPERATOR(POW) +DEF_SCHEMA_OPERATOR(SUB) +DEF_SCHEMA_OPERATOR(TABLE) +DEF_SCHEMA_OPERATOR(ABS) +DEF_SCHEMA_OPERATOR(BITWISE_NOT) +DEF_SCHEMA_OPERATOR(CEIL) +DEF_SCHEMA_OPERATOR(CLZ) +DEF_SCHEMA_OPERATOR(EXP) +DEF_SCHEMA_OPERATOR(FLOOR) +DEF_SCHEMA_OPERATOR(LOG) +DEF_SCHEMA_OPERATOR(LOGICAL_NOT) +DEF_SCHEMA_OPERATOR(NEGATE) +DEF_SCHEMA_OPERATOR(RECIPROCAL) +DEF_SCHEMA_OPERATOR(RSQRT) +DEF_SCHEMA_OPERATOR(SELECT) +DEF_SCHEMA_OPERATOR(EQUAL) +DEF_SCHEMA_OPERATOR(GREATER) +DEF_SCHEMA_OPERATOR(GREATER_EQUAL) +DEF_SCHEMA_OPERATOR(REDUCE_ANY) +DEF_SCHEMA_OPERATOR(REDUCE_ALL) +DEF_SCHEMA_OPERATOR(REDUCE_MAX) +DEF_SCHEMA_OPERATOR(REDUCE_MIN) +DEF_SCHEMA_OPERATOR(REDUCE_PRODUCT) +DEF_SCHEMA_OPERATOR(REDUCE_SUM) +DEF_SCHEMA_OPERATOR(CONCAT) +DEF_SCHEMA_OPERATOR(PAD) +DEF_SCHEMA_OPERATOR(RESHAPE) +DEF_SCHEMA_OPERATOR(REVERSE) +DEF_SCHEMA_OPERATOR(SLICE) +DEF_SCHEMA_OPERATOR(TILE) +DEF_SCHEMA_OPERATOR(TRANSPOSE) +DEF_SCHEMA_OPERATOR(GATHER) +DEF_SCHEMA_OPERATOR(SCATTER) +DEF_SCHEMA_OPERATOR(RESIZE) +DEF_SCHEMA_OPERATOR(CAST) +DEF_SCHEMA_OPERATOR(RESCALE) +DEF_SCHEMA_OPERATOR(CONST) +DEF_SCHEMA_OPERATOR(IDENTITY) +DEF_SCHEMA_OPERATOR(CUSTOM) +DEF_SCHEMA_OPERATOR(COND_IF) +DEF_SCHEMA_OPERATOR(WHILE_LOOP) +DEF_SCHEMA_OPERATOR(FFT2D) +DEF_SCHEMA_OPERATOR(RFFT2D) -- cgit v1.2.1