diff options
author | Chunseok Lee <chunseok.lee@samsung.com> | 2020-10-29 13:12:50 +0900 |
---|---|---|
committer | Chunseok Lee <chunseok.lee@samsung.com> | 2020-10-29 13:12:50 +0900 |
commit | d6b371e095d737922187a518b8faba1ef6f3a2b1 (patch) | |
tree | 9d90c09c887b5111389dbedf924f59206411cd5a /compiler/tflchef | |
parent | c55f8a6db48cda9d3a78048338b7f18c4cca62b8 (diff) | |
download | nnfw-d6b371e095d737922187a518b8faba1ef6f3a2b1.tar.gz nnfw-d6b371e095d737922187a518b8faba1ef6f3a2b1.tar.bz2 nnfw-d6b371e095d737922187a518b8faba1ef6f3a2b1.zip |
Imported Upstream version 0.4upstream/0.4
Diffstat (limited to 'compiler/tflchef')
470 files changed, 1936 insertions, 18614 deletions
diff --git a/compiler/tflchef/CMakeLists.txt b/compiler/tflchef/CMakeLists.txt index ebc873342..2cec026f2 100644 --- a/compiler/tflchef/CMakeLists.txt +++ b/compiler/tflchef/CMakeLists.txt @@ -1,19 +1,16 @@ -nnas_find_package(Protobuf QUIET) +nncc_find_package(FlatBuffers QUIET) +nncc_find_package(Protobuf QUIET) -if(NOT Protobuf_FOUND) - message(STATUS "Build tflchef: FAILED (missing Protobuf)") +if(NOT FlatBuffers_FOUND) return() -endif(NOT Protobuf_FOUND) +endif(NOT FlatBuffers_FOUND) -if(NOT TARGET mio_tflite) - message(STATUS "Build tflchef: FAILED (missing mio_tflite)") +if(NOT Protobuf_FOUND) return() -endif(NOT TARGET mio_tflite) +endif(NOT Protobuf_FOUND) # Recipe Parser add_subdirectory(proto) -# Log -add_subdirectory(log) # Core Library add_subdirectory(core) # TFlite Library diff --git a/compiler/tflchef/core/CMakeLists.txt b/compiler/tflchef/core/CMakeLists.txt index 43f6b8b03..a9bc82180 100644 --- a/compiler/tflchef/core/CMakeLists.txt +++ b/compiler/tflchef/core/CMakeLists.txt @@ -1,9 +1,12 @@ +FlatBuffers_Target(tflchef_flatbuffer + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/schema/tflite" + SCHEMA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/schema" + SCHEMA_FILES tflite.fbs) + file(GLOB_RECURSE SOURCES "src/*.cpp") add_library(tflchef_core STATIC ${SOURCES}) target_include_directories(tflchef_core PUBLIC include) target_include_directories(tflchef_core PRIVATE src) target_link_libraries(tflchef_core tflchef_proto) -target_link_libraries(tflchef_core tflchef_log) -target_link_libraries(tflchef_core mio_tflite) -target_link_libraries(tflchef_core souschef) +target_link_libraries(tflchef_core tflchef_flatbuffer) diff --git a/compiler/tflchef/core/schema/tflite.fbs b/compiler/tflchef/core/schema/tflite.fbs new file mode 100644 index 000000000..3da3188c3 --- /dev/null +++ b/compiler/tflchef/core/schema/tflite.fbs @@ -0,0 +1,698 @@ +// Copyright 2017 The TensorFlow Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +// Revision History +// Version 0: Initial version. +// Version 1: Add subgraphs to schema. +// Version 2: Rename operators to conform to NN API. +// Version 3: Move buffer data from Model.Subgraph.Tensors to Model.Buffers. + +namespace tflite; + +// This corresponds to the version. +file_identifier "TFL3"; +// File extension of any written files. +file_extension "tflite"; + +// The type of data stored in a tensor. +enum TensorType : byte { + FLOAT32 = 0, + FLOAT16 = 1, + INT32 = 2, + UINT8 = 3, + INT64 = 4, + STRING = 5, + BOOL = 6, + INT16 = 7, + COMPLEX64 = 8, +} + +// Parameters for converting a quantized tensor back to float. Given a +// quantized value q, the corresponding float value f should be: +// f = scale * (q - zero_point) +table QuantizationParameters { + min:[float]; // For importing back into tensorflow. + max:[float]; // For importing back into tensorflow. + scale:[float]; // For dequantizing the tensor's values. + zero_point:[long]; +} + +table Tensor { + // The tensor shape. The meaning of each entry is operator-specific but + // builtin ops use: [batch size, height, width, number of channels] (That's + // Tensorflow's NHWC). + shape:[int]; + type:TensorType; + // An index that refers to the buffers table at the root of the model. Or, + // if there is no data buffer associated (i.e. intermediate results), then + // this is 0 (which refers to an always existent empty buffer). + // + // The data_buffer itself is an opaque container, with the assumption that the + // target device is little-endian. In addition, all builtin operators assume + // the memory is ordered such that if `shape` is [4, 3, 2], then index + // [i, j, k] maps to data_buffer[i*3*2 + j*2 + k]. + buffer:uint; + name:string; // For debugging and importing back into tensorflow. + quantization:QuantizationParameters; // Optional. + + is_variable:bool = false; +} + +// A list of builtin operators. Builtin operators are slightly faster than custom +// ones, but not by much. Moreover, while custom operators accept an opaque +// object containing configuration parameters, builtins have a predetermined +// set of acceptable options. +enum BuiltinOperator : byte { + ADD = 0, + AVERAGE_POOL_2D = 1, + CONCATENATION = 2, + CONV_2D = 3, + DEPTHWISE_CONV_2D = 4, + // DEPTH_TO_SPACE = 5, + DEQUANTIZE = 6, + EMBEDDING_LOOKUP = 7, + FLOOR = 8, + FULLY_CONNECTED = 9, + HASHTABLE_LOOKUP = 10, + L2_NORMALIZATION = 11, + L2_POOL_2D = 12, + LOCAL_RESPONSE_NORMALIZATION = 13, + LOGISTIC = 14, + LSH_PROJECTION = 15, + LSTM = 16, + MAX_POOL_2D = 17, + MUL = 18, + RELU = 19, + // NOTE(aselle): RELU_N1_TO_1 used to be called RELU1, but it was renamed + // since different model developers use RELU1 in different ways. Never + // create another op called RELU1. + RELU_N1_TO_1 = 20, + RELU6 = 21, + RESHAPE = 22, + RESIZE_BILINEAR = 23, + RNN = 24, + SOFTMAX = 25, + SPACE_TO_DEPTH = 26, + SVDF = 27, + TANH = 28, + // TODO(aselle): Consider rename to CONCATENATE_EMBEDDINGS + CONCAT_EMBEDDINGS = 29, + SKIP_GRAM = 30, + CALL = 31, + CUSTOM = 32, + EMBEDDING_LOOKUP_SPARSE = 33, + PAD = 34, + UNIDIRECTIONAL_SEQUENCE_RNN = 35, + GATHER = 36, + BATCH_TO_SPACE_ND = 37, + SPACE_TO_BATCH_ND = 38, + TRANSPOSE = 39, + MEAN = 40, + SUB = 41, + DIV = 42, + SQUEEZE = 43, + UNIDIRECTIONAL_SEQUENCE_LSTM = 44, + STRIDED_SLICE = 45, + BIDIRECTIONAL_SEQUENCE_RNN = 46, + EXP = 47, + TOPK_V2 = 48, + SPLIT = 49, + LOG_SOFTMAX = 50, + // DELEGATE is a special op type for the operations which are delegated to + // other backends. + // WARNING: Experimental interface, subject to change + DELEGATE = 51, + BIDIRECTIONAL_SEQUENCE_LSTM = 52, + CAST = 53, + PRELU = 54, + MAXIMUM = 55, + ARG_MAX = 56, + MINIMUM = 57, + LESS = 58, + NEG = 59, + PADV2 = 60, + GREATER = 61, + GREATER_EQUAL = 62, + LESS_EQUAL = 63, + SELECT = 64, + SLICE = 65, + SIN = 66, + TRANSPOSE_CONV = 67, + SPARSE_TO_DENSE = 68, + TILE = 69, + EXPAND_DIMS = 70, + EQUAL = 71, + NOT_EQUAL = 72, + LOG = 73, + SUM = 74, + SQRT = 75, + RSQRT = 76, + SHAPE = 77, + POW = 78, + ARG_MIN = 79, + FAKE_QUANT = 80, + REDUCE_PROD = 81, + REDUCE_MAX = 82, + PACK = 83, + LOGICAL_OR = 84, + ONE_HOT = 85, + LOGICAL_AND = 86, + LOGICAL_NOT = 87, + UNPACK = 88, + REDUCE_MIN = 89, + FLOOR_DIV = 90, + REDUCE_ANY = 91, + SQUARE = 92, + ZEROS_LIKE = 93, + FILL = 94, +} + +// Options for the builtin operators. +union BuiltinOptions { + Conv2DOptions, + DepthwiseConv2DOptions, + ConcatEmbeddingsOptions, + LSHProjectionOptions, + Pool2DOptions, + SVDFOptions, + RNNOptions, + FullyConnectedOptions, + SoftmaxOptions, + ConcatenationOptions, + AddOptions, + L2NormOptions, + LocalResponseNormalizationOptions, + LSTMOptions, + ResizeBilinearOptions, + CallOptions, + ReshapeOptions, + SkipGramOptions, + SpaceToDepthOptions, + EmbeddingLookupSparseOptions, + MulOptions, + PadOptions, + GatherOptions, + BatchToSpaceNDOptions, + SpaceToBatchNDOptions, + TransposeOptions, + ReducerOptions, + SubOptions, + DivOptions, + SqueezeOptions, + SequenceRNNOptions, + StridedSliceOptions, + ExpOptions, + TopKV2Options, + SplitOptions, + LogSoftmaxOptions, + CastOptions, + DequantizeOptions, + MaximumMinimumOptions, + ArgMaxOptions, + LessOptions, + NegOptions, + PadV2Options, + GreaterOptions, + GreaterEqualOptions, + LessEqualOptions, + SelectOptions, + SliceOptions, + TransposeConvOptions, + SparseToDenseOptions, + TileOptions, + ExpandDimsOptions, + EqualOptions, + NotEqualOptions, + ShapeOptions, + PowOptions, + ArgMinOptions, + FakeQuantOptions, + PackOptions, + LogicalOrOptions, + OneHotOptions, + LogicalAndOptions, + LogicalNotOptions, + UnpackOptions, + FloorDivOptions, + SquareOptions, + ZerosLikeOptions, + FillOptions, +} + +enum Padding : byte { SAME, VALID } + +enum ActivationFunctionType : byte { + NONE = 0, + RELU = 1, + RELU_N1_TO_1 = 2, + RELU6 = 3, + TANH = 4, + SIGN_BIT = 5, +} + +table Conv2DOptions { + padding:Padding; + stride_w:int; + stride_h:int; + fused_activation_function:ActivationFunctionType; + dilation_w_factor:int = 1; + dilation_h_factor:int = 1; +} + +table Pool2DOptions { + padding:Padding; + stride_w:int; + stride_h:int; + filter_width:int; + filter_height:int; + fused_activation_function:ActivationFunctionType; +} + +table DepthwiseConv2DOptions { + // Parameters for DepthwiseConv version 1 or above. + padding:Padding; + stride_w:int; + stride_h:int; + depth_multiplier:int; + fused_activation_function:ActivationFunctionType; + // Parameters for DepthwiseConv version 2 or above. + dilation_w_factor:int = 1; + dilation_h_factor:int = 1; +} + +table ConcatEmbeddingsOptions { + num_channels:int; + num_columns_per_channel:[int]; + embedding_dim_per_channel:[int]; // This could be inferred from parameters. +} + +enum LSHProjectionType: byte { + UNKNOWN = 0, + SPARSE = 1, + DENSE = 2, +} + +table LSHProjectionOptions { + type: LSHProjectionType; +} + +table SVDFOptions { + rank:int; + fused_activation_function:ActivationFunctionType; +} + +// An implementation of TensorFlow RNNCell. +table RNNOptions { + fused_activation_function:ActivationFunctionType; +} + +// An implementation of TensorFlow dynamic_rnn with RNNCell. +table SequenceRNNOptions { + time_major:bool; + fused_activation_function:ActivationFunctionType; +} + +// An implementation of TensorFlow bidrectional_dynamic_rnn with RNNCell. +table BidirectionalSequenceRNNOptions { + time_major:bool; + fused_activation_function:ActivationFunctionType; +} + +enum FullyConnectedOptionsWeightsFormat: byte { + DEFAULT = 0, + SHUFFLED4x16INT8 = 1, +} + +// An implementation of TensorFlow fully_connected (a.k.a Dense) layer. +table FullyConnectedOptions { + // Parameters for FullyConnected version 1 or above. + fused_activation_function:ActivationFunctionType; + + // Parameters for FullyConnected version 2 or above. + weights_format:FullyConnectedOptionsWeightsFormat = DEFAULT; +} + +table SoftmaxOptions { + beta: float; +} + +// An implementation of TensorFlow concat. +table ConcatenationOptions { + axis:int; + fused_activation_function:ActivationFunctionType; +} + +table AddOptions { + fused_activation_function:ActivationFunctionType; +} + +table MulOptions { + fused_activation_function:ActivationFunctionType; +} + +table L2NormOptions { + fused_activation_function:ActivationFunctionType; +} + +table LocalResponseNormalizationOptions { + radius:int; + bias:float; + alpha:float; + beta:float; +} + +enum LSTMKernelType : byte { + // Full LSTM kernel which supports peephole and projection. + FULL = 0, + // Basic LSTM kernels. Equivalent to TensorFlow BasicLSTMCell. + BASIC = 1, +} + +// An implementation of TensorFlow LSTMCell and CoupledInputForgetGateLSTMCell +table LSTMOptions { + // Parameters for LSTM version 1 or above. + fused_activation_function:ActivationFunctionType; + cell_clip: float; // Optional, 0.0 means no clipping + proj_clip: float; // Optional, 0.0 means no clipping + + // Parameters for LSTM version 2 or above. + // Basic kernel is only supported in version 2 or above. + kernel_type: LSTMKernelType = FULL; +} + +table ResizeBilinearOptions { + new_height: int (deprecated); + new_width: int (deprecated); + align_corners: bool; +} + +// A call operation options +table CallOptions { + // The subgraph index that needs to be called. + subgraph:uint; +} + +table PadOptions { +} + +table PadV2Options { +} + +table ReshapeOptions { + new_shape:[int]; +} + +table SpaceToBatchNDOptions { +} + +table BatchToSpaceNDOptions { +} + +table SkipGramOptions { + ngram_size: int; + max_skip_size: int; + include_all_ngrams: bool; +} + +table SpaceToDepthOptions { + block_size: int; +} + +table SubOptions { + fused_activation_function:ActivationFunctionType; +} + +table DivOptions { + fused_activation_function:ActivationFunctionType; +} + +table TopKV2Options { +} + +enum CombinerType : byte { + SUM = 0, + MEAN = 1, + SQRTN = 2, +} + +table EmbeddingLookupSparseOptions { + combiner:CombinerType; +} + +table GatherOptions { + axis: int; +} + +table TransposeOptions { +} + +table ExpOptions { +} + +table ReducerOptions { + keep_dims: bool; +} + +table SqueezeOptions { + squeeze_dims:[int]; +} + +table SplitOptions { + num_splits: int; +} + +table StridedSliceOptions { + begin_mask: int; + end_mask: int; + ellipsis_mask: int; + new_axis_mask: int; + shrink_axis_mask: int; +} + +table LogSoftmaxOptions { +} + +table CastOptions { + in_data_type: TensorType; + out_data_type: TensorType; +} + +table DequantizeOptions { +} + +table MaximumMinimumOptions { +} + +table TileOptions { +} + +table ArgMaxOptions { + output_type : TensorType; +} + +table ArgMinOptions { + output_type : TensorType; +} + +table GreaterOptions { +} + +table GreaterEqualOptions { +} + +table LessOptions { +} + +table LessEqualOptions { +} + +table NegOptions { +} + +table SelectOptions { +} + +table SliceOptions { +} + +table TransposeConvOptions { + padding:Padding; + stride_w:int; + stride_h:int; +} + +table ExpandDimsOptions { +} + +table SparseToDenseOptions { + validate_indices:bool; +} + +table EqualOptions { +} + +table NotEqualOptions { +} + +table ShapeOptions { + // Optional output type of the operation (int32 or int64). Defaults to int32. + out_type : TensorType; +} + +table PowOptions { +} + +table FakeQuantOptions { + // Parameters supported by version 1: + min:float; + max:float; + num_bits:int; + + // Parameters supported by version 2: + narrow_range:bool; +} + +table PackOptions { + values_count:int; + axis:int; +} + +table LogicalOrOptions { +} + +table OneHotOptions { + axis:int; +} + +table LogicalAndOptions { +} + +table LogicalNotOptions { +} + +table UnpackOptions { + num:int; + axis:int; +} + +table FloorDivOptions { +} + +table SquareOptions { +} + +table ZerosLikeOptions { +} + +table FillOptions { +} + +// An OperatorCode can be an enum value (BuiltinOperator) if the operator is a +// builtin, or a string if the operator is custom. +table OperatorCode { + builtin_code:BuiltinOperator; + custom_code:string; + + // The version of the operator. The version need to be bumped whenever new + // parameters are introduced into an op. + version:int = 1; +} + +enum CustomOptionsFormat : byte { + FLEXBUFFERS = 0, +} + +// An operator takes tensors as inputs and outputs. The type of operation being +// performed is determined by an index into the list of valid OperatorCodes, +// while the specifics of each operations is configured using builtin_options +// or custom_options. +table Operator { + // Index into the operator_codes array. Using an integer here avoids + // complicate map lookups. + opcode_index:uint; + + // Optional input and output tensors are indicated by -1. + inputs:[int]; + outputs:[int]; + + builtin_options:BuiltinOptions; + custom_options:[ubyte]; + custom_options_format:CustomOptionsFormat; + + // A list of booleans indicating the input tensors which are being mutated by + // this operator.(e.g. used by RNN and LSTM). + // For example, if the "inputs" array refers to 5 tensors and the second and + // fifth are mutable variables, then this list will contain + // [false, true, false, false, true]. + // + // If the list is empty, no variable is mutated in this operator. + // The list either has the same length as `inputs`, or is empty. + mutating_variable_inputs:[bool]; +} + +// The root type, defining a subgraph, which typically represents an entire +// model. +table SubGraph { + // A list of all tensors used in this subgraph. + tensors:[Tensor]; + + // Indices of the tensors that are inputs into this subgraph. Note this is + // the list of non-static tensors that feed into the subgraph for inference. + inputs:[int]; + + // Indices of the tensors that are outputs out of this subgraph. Note this is + // the list of output tensors that are considered the product of the + // subgraph's inference. + outputs:[int]; + + // All operators, in execution order. + operators:[Operator]; + + // Name of this subgraph (used for debugging). + name:string; +} + +// Table of raw data buffers (used for constant tensors). Referenced by tensors +// by index. The generous alignment accommodates mmap-friendly data structures. +table Buffer { + data:[ubyte] (force_align: 16); +} + +table Model { + // Version of the schema. + version:uint; + + // A list of all operator codes used in this model. This is + // kept in order because operators carry an index into this + // vector. + operator_codes:[OperatorCode]; + + // All the subgraphs of the model. The 0th is assumed to be the main + // model. + subgraphs:[SubGraph]; + + // A description of the model. + description:string; + + // Buffers of the model. + // Note the 0th entry of this array must be an empty buffer (sentinel). + // This is a convention so that tensors without a buffer can provide 0 as + // their buffer. + buffers:[Buffer]; + + // Metadata about the model. Indirects into the existings buffers list. + metadata_buffer:[int]; +} + +root_type Model; diff --git a/compiler/tflchef/core/schema/tflite.meta b/compiler/tflchef/core/schema/tflite.meta new file mode 100644 index 000000000..cd90a3d63 --- /dev/null +++ b/compiler/tflchef/core/schema/tflite.meta @@ -0,0 +1,2 @@ +URL="https://raw.githubusercontent.com/tensorflow/tensorflow/a6d8ffae097/tensorflow/contrib/lite/schema/schema.fbs" +NOTE="TensorFlow Lite Schema from TensorFlow v1.12.0 release" diff --git a/compiler/tflchef/core/src/Op/ELU.cpp b/compiler/tflchef/core/src/Arguments.h index d9dae16af..341aea6c9 100644 --- a/compiler/tflchef/core/src/Op/ELU.cpp +++ b/compiler/tflchef/core/src/Arguments.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,21 @@ * limitations under the License. */ -#include "ELU.h" +#ifndef __ARGUMENTS_H__ +#define __ARGUMENTS_H__ -flatbuffers::Offset<void> ELUChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} +#include <cstdint> +#include <string> -std::unique_ptr<OpChef> ELUChefFactory::create(const tflchef::Operation *operation) const +/** + * @brief Read-only string sequence view + */ +struct Arguments { - return std::unique_ptr<OpChef>{new ELUChef{operation}}; -} + virtual ~Arguments() = default; + + virtual uint32_t count(void) const = 0; + virtual const std::string &value(uint32_t n) const = 0; +}; + +#endif // __ARGUMENTS_H__ diff --git a/compiler/tflchef/core/src/Convert.cpp b/compiler/tflchef/core/src/Convert.cpp index 9602faa96..8e4f1d392 100644 --- a/compiler/tflchef/core/src/Convert.cpp +++ b/compiler/tflchef/core/src/Convert.cpp @@ -41,14 +41,8 @@ tflite::ActivationFunctionType as_tflite_activation(const tflchef::Activation &v return tflite::ActivationFunctionType_NONE; case tflchef::RELU: return tflite::ActivationFunctionType_RELU; - case tflchef::RELU_N1_TO_1: - return tflite::ActivationFunctionType_RELU_N1_TO_1; case tflchef::RELU6: return tflite::ActivationFunctionType_RELU6; - case tflchef::TANH: - return tflite::ActivationFunctionType_TANH; - case tflchef::SIGN_BIT: - return tflite::ActivationFunctionType_SIGN_BIT; default: break; } @@ -64,99 +58,9 @@ tflite::TensorType as_tflite_tensortype(const tflchef::TensorType &value) return tflite::TensorType_FLOAT32; case tflchef::INT32: return tflite::TensorType_INT32; - case tflchef::UINT8: - return tflite::TensorType_UINT8; - case tflchef::INT64: - return tflite::TensorType_INT64; - case tflchef::BOOL: - return tflite::TensorType_BOOL; default: break; } throw std::runtime_error{"Unknown tensor type"}; } - -tflite::MirrorPadMode as_tflite_mirrorpadmode(const tflchef::MirrorPadMode &value) -{ - switch (value) - { - case tflchef::REFLECT: - return tflite::MirrorPadMode_REFLECT; - case tflchef::SYMMETRIC: - return tflite::MirrorPadMode_SYMMETRIC; - default: - break; - } - - throw std::runtime_error{"Unknown mirrorpad mode"}; -} - -tflite::DimensionType as_tflite_dimensiontype(const tflchef::DimensionType &value) -{ - switch (value) - { - case tflchef::DimensionType::DENSE: - return tflite::DimensionType_DENSE; - case tflchef::DimensionType::SPARSE_CSR: - return tflite::DimensionType_SPARSE_CSR; - default: - break; - } - - throw std::runtime_error("Unknown dimension type"); -} - -tflite::SparseIndexVector as_tflite_sparse_idx_vec_type(const tflchef::SparseIndexVecType &value) -{ - switch (value) - { - case tflchef::SparseIndexVecType::SparseIdxVecType_NONE: - return tflite::SparseIndexVector_NONE; - case tflchef::SparseIndexVecType::INT32VEC: - return tflite::SparseIndexVector_Int32Vector; - case tflchef::SparseIndexVecType::UINT16VEC: - return tflite::SparseIndexVector_Uint16Vector; - case tflchef::SparseIndexVecType::UINT8VEC: - return tflite::SparseIndexVector_Uint8Vector; - default: - break; - } - - throw std::runtime_error("Unknown SparseIndexVector type"); -} - -flatbuffers::Offset<void> -as_tflite_sparse_index_vec(flatbuffers::FlatBufferBuilder &fb, - const ::tflchef::TensorSparsity_IndexVec &value) -{ - auto sparse_idx_type = value.type(); - - switch (sparse_idx_type) - { - case tflchef::SparseIndexVecType::SparseIdxVecType_NONE: - return flatbuffers::Offset<void>(); - case tflchef::SparseIndexVecType::INT32VEC: - { - auto values_vec_int32 = std::vector<int32_t>{value.dim().begin(), value.dim().end()}; - auto values_int32 = fb.CreateVector(values_vec_int32); - return tflite::CreateInt32Vector(fb, values_int32).Union(); - } - case tflchef::SparseIndexVecType::UINT16VEC: - { - auto values_vec_uint16 = std::vector<uint16_t>{value.dim().begin(), value.dim().end()}; - auto values_uint16 = fb.CreateVector(values_vec_uint16); - return tflite::CreateUint16Vector(fb, values_uint16).Union(); - } - case tflchef::SparseIndexVecType::UINT8VEC: - { - auto values_vec_uint8 = std::vector<uint8_t>{value.dim().begin(), value.dim().end()}; - auto values_uint8 = fb.CreateVector(values_vec_uint8); - return tflite::CreateUint8Vector(fb, values_uint8).Union(); - } - default: - break; - } - - throw std::runtime_error("Unknown SparseIndexVector type"); -} diff --git a/compiler/tflchef/core/src/Convert.h b/compiler/tflchef/core/src/Convert.h index 45c93d229..1685fcbc3 100644 --- a/compiler/tflchef/core/src/Convert.h +++ b/compiler/tflchef/core/src/Convert.h @@ -22,16 +22,10 @@ #define __CONVERT_H__ #include <tflchef.pb.h> -#include <mio/tflite/schema_generated.h> +#include <tflite_generated.h> tflite::Padding as_tflite_padding(const tflchef::Padding &value); tflite::ActivationFunctionType as_tflite_activation(const tflchef::Activation &value); tflite::TensorType as_tflite_tensortype(const tflchef::TensorType &value); -tflite::MirrorPadMode as_tflite_mirrorpadmode(const tflchef::MirrorPadMode &value); -tflite::DimensionType as_tflite_dimensiontype(const tflchef::DimensionType &value); -tflite::SparseIndexVector as_tflite_sparse_idx_vec_type(const tflchef::SparseIndexVecType &value); -flatbuffers::Offset<void> -as_tflite_sparse_index_vec(flatbuffers::FlatBufferBuilder &fb, - const ::tflchef::TensorSparsity_IndexVec &value); #endif // __CONVERT_H__ diff --git a/compiler/tflchef/core/src/CustomOp/AddV2.cpp b/compiler/tflchef/core/src/CustomOp/AddV2.cpp deleted file mode 100644 index dffd336cd..000000000 --- a/compiler/tflchef/core/src/CustomOp/AddV2.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * Copyright 2015 The TensorFlow Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "AddV2.h" - -#include "flatbuffers/flexbuffers.h" - -flatbuffers::Offset<void> AddV2Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} - -flatbuffers::Offset<flatbuffers::Vector<uint8_t>> -AddV2Chef::custom_value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.type() == "AddV2"); - - /** - * REGISTER_OP("AddV2") - .Input("x: T") - .Input("y: T") - .Output("z: T") - .Attr( - "T: {bfloat16, half, float, double, uint8, int8, int16, int32, int64, " - "complex64, complex128}") - .SetShapeFn(shape_inference::BroadcastBinaryOpShapeFn) - .SetIsAggregate() - .SetIsCommutative(); - */ - - auto flex_buffers = std::make_unique<flexbuffers::Builder>(); - size_t map_start = flex_buffers->StartMap(); - - // TODO Support more data types - flex_buffers->Int("T", tflite::TensorType_FLOAT32); - - flex_buffers->EndMap(map_start); - flex_buffers->Finish(); - - auto circle_custom_options = fbb.CreateVector(flex_buffers->GetBuffer()); - return circle_custom_options; -} - -std::unique_ptr<OpChef> AddV2ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new AddV2Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/CustomOp/AddV2.h b/compiler/tflchef/core/src/CustomOp/AddV2.h deleted file mode 100644 index dbbaf5a62..000000000 --- a/compiler/tflchef/core/src/CustomOp/AddV2.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ADDV2_H__ -#define __OP_ADDV2_H__ - -#include "OpChef.h" - -class AddV2Chef final : public OpChef -{ -public: - explicit AddV2Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_CUSTOM; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - - flatbuffers::Offset<flatbuffers::Vector<uint8_t>> - custom_value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct AddV2ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ADDV2_H__ diff --git a/compiler/tflchef/core/src/CustomOp/All.cpp b/compiler/tflchef/core/src/CustomOp/All.cpp deleted file mode 100644 index b3ae821a4..000000000 --- a/compiler/tflchef/core/src/CustomOp/All.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * Copyright 2015 The TensorFlow Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "All.h" - -#include "flatbuffers/flexbuffers.h" - -flatbuffers::Offset<void> AllChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} - -flatbuffers::Offset<flatbuffers::Vector<uint8_t>> -AllChef::custom_value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.type() == "All"); - - /** - * REGISTER_OP("All") - .Input("input: bool") - .Input("reduction_indices: Tidx") - .Output("output: bool") - .Attr("keep_dims: bool = false") - .Attr("Tidx: {int32, int64} = DT_INT32") - .SetShapeFn(shape_inference::ReductionShape); - */ - - auto flex_buffers = std::make_unique<flexbuffers::Builder>(); - size_t map_start = flex_buffers->StartMap(); - - // TODO Support more data types - flex_buffers->Int("Tidx", tflite::TensorType_INT32); - flex_buffers->Bool("keep_dims", operation.all_options().keep_dims()); - - flex_buffers->EndMap(map_start); - flex_buffers->Finish(); - - auto circle_custom_options = fbb.CreateVector(flex_buffers->GetBuffer()); - return circle_custom_options; -} - -std::unique_ptr<OpChef> AllChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new AllChef{operation}}; -} diff --git a/compiler/tflchef/core/src/CustomOp/All.h b/compiler/tflchef/core/src/CustomOp/All.h deleted file mode 100644 index f7949f3d2..000000000 --- a/compiler/tflchef/core/src/CustomOp/All.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ALL_H__ -#define __OP_ALL_H__ - -#include "OpChef.h" - -class AllChef final : public OpChef -{ -public: - explicit AllChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_CUSTOM; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - - flatbuffers::Offset<flatbuffers::Vector<uint8_t>> - custom_value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct AllChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ALL_H__ diff --git a/compiler/tflchef/core/src/CustomOp/BatchMatMulV2.cpp b/compiler/tflchef/core/src/CustomOp/BatchMatMulV2.cpp deleted file mode 100644 index 595f3b9bb..000000000 --- a/compiler/tflchef/core/src/CustomOp/BatchMatMulV2.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * Copyright 2015 The TensorFlow Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "BatchMatMulV2.h" - -#include "flatbuffers/flexbuffers.h" - -flatbuffers::Offset<void> BatchMatMulV2Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} - -flatbuffers::Offset<flatbuffers::Vector<uint8_t>> -BatchMatMulV2Chef::custom_value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.type() == "BatchMatMulV2"); - - /** - * REGISTER_OP("BatchMatMulV2") - .Input("x: T") - .Input("y: T") - .Output("output: T") - .Attr( - "T: {bfloat16, half, float, double, int32, int64, complex64, " - "complex128}") - .Attr("adj_x: bool = false") - .Attr("adj_y: bool = false") - .SetShapeFn(shape_inference::BatchMatMulV2Shape); - */ - - auto flex_buffers = std::make_unique<flexbuffers::Builder>(); - size_t map_start = flex_buffers->StartMap(); - - flex_buffers->Bool("adj_x", operation.batch_matmul_options().adj_x()); - flex_buffers->Bool("adj_y", operation.batch_matmul_options().adj_y()); - // TODO Support more data types - flex_buffers->Int("T", tflite::TensorType_FLOAT32); - - flex_buffers->EndMap(map_start); - flex_buffers->Finish(); - - auto circle_custom_options = fbb.CreateVector(flex_buffers->GetBuffer()); - return circle_custom_options; -} - -std::unique_ptr<OpChef> BatchMatMulV2ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new BatchMatMulV2Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/CustomOp/BatchMatMulV2.h b/compiler/tflchef/core/src/CustomOp/BatchMatMulV2.h deleted file mode 100644 index d20f4d2a5..000000000 --- a/compiler/tflchef/core/src/CustomOp/BatchMatMulV2.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_BATCH_MATMUL_V2_H__ -#define __OP_BATCH_MATMUL_V2_H__ - -#include "OpChef.h" - -class BatchMatMulV2Chef final : public OpChef -{ -public: - explicit BatchMatMulV2Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_CUSTOM; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - - flatbuffers::Offset<flatbuffers::Vector<uint8_t>> - custom_value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct BatchMatMulV2ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_BATCH_MATMUL_V2_H__ diff --git a/compiler/tflchef/core/src/CustomOp/MatMul.cpp b/compiler/tflchef/core/src/CustomOp/MatMul.cpp deleted file mode 100644 index ba34aa8db..000000000 --- a/compiler/tflchef/core/src/CustomOp/MatMul.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * Copyright 2015 The TensorFlow Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MatMul.h" - -#include "flatbuffers/flexbuffers.h" - -flatbuffers::Offset<void> MatMulChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} - -flatbuffers::Offset<flatbuffers::Vector<uint8_t>> -MatMulChef::custom_value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.type() == "MatMul"); - - /** - * REGISTER_OP("MatMul") - .Input("a: T") - .Input("b: T") - .Output("product: T") - .Attr("transpose_a: bool = false") - .Attr("transpose_b: bool = false") - .Attr("T: {half, float, double, int32, complex64, complex128}") - .SetShapeFn(shape_inference::MatMulShape) - */ - - auto flex_buffers = std::make_unique<flexbuffers::Builder>(); - size_t map_start = flex_buffers->StartMap(); - - flex_buffers->Bool("transpose_a", operation.matmul_options().transpose_a()); - flex_buffers->Bool("transpose_b", operation.matmul_options().transpose_b()); - // TODO how do we support other types? - flex_buffers->Int("T", tflite::TensorType_FLOAT32); - - flex_buffers->EndMap(map_start); - flex_buffers->Finish(); - - auto circle_custom_options = fbb.CreateVector(flex_buffers->GetBuffer()); - return circle_custom_options; -} - -std::unique_ptr<OpChef> MatMulChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MatMulChef{operation}}; -} diff --git a/compiler/tflchef/core/src/CustomOp/MatMul.h b/compiler/tflchef/core/src/CustomOp/MatMul.h deleted file mode 100644 index b0307f977..000000000 --- a/compiler/tflchef/core/src/CustomOp/MatMul.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MATMUL_H__ -#define __OP_MATMUL_H__ - -#include "OpChef.h" - -class MatMulChef final : public OpChef -{ -public: - explicit MatMulChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_CUSTOM; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - - flatbuffers::Offset<flatbuffers::Vector<uint8_t>> - custom_value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MatMulChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MATMUL_H__ diff --git a/compiler/tflchef/core/src/CustomOp/MatrixBandPart.cpp b/compiler/tflchef/core/src/CustomOp/MatrixBandPart.cpp deleted file mode 100644 index d12597edb..000000000 --- a/compiler/tflchef/core/src/CustomOp/MatrixBandPart.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * Copyright 2015 The TensorFlow Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MatrixBandPart.h" - -#include "flatbuffers/flexbuffers.h" - -flatbuffers::Offset<void> MatrixBandPartChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} - -flatbuffers::Offset<flatbuffers::Vector<uint8_t>> -MatrixBandPartChef::custom_value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.type() == "MatrixBandPart"); - - /** - * REGISTER_OP("MatrixBandPart") - .Input("input: T") - .Input("num_lower: Tindex") - .Input("num_upper: Tindex") - .Output("band: T") - .Attr("T: type") - .Attr("Tindex: {int32, int64} = DT_INT64") - .SetShapeFn(shape_inference::UnchangedShape); - */ - - auto flex_buffers = std::make_unique<flexbuffers::Builder>(); - size_t map_start = flex_buffers->StartMap(); - - // TODO Support more data types - flex_buffers->Int("T", tflite::TensorType_FLOAT32); - flex_buffers->Int("Tindex", tflite::TensorType_INT64); - - flex_buffers->EndMap(map_start); - flex_buffers->Finish(); - - auto circle_custom_options = fbb.CreateVector(flex_buffers->GetBuffer()); - return circle_custom_options; -} - -std::unique_ptr<OpChef> MatrixBandPartChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MatrixBandPartChef{operation}}; -} diff --git a/compiler/tflchef/core/src/CustomOp/MatrixBandPart.h b/compiler/tflchef/core/src/CustomOp/MatrixBandPart.h deleted file mode 100644 index 54a8a3afb..000000000 --- a/compiler/tflchef/core/src/CustomOp/MatrixBandPart.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MATRIXBANDPART_H__ -#define __OP_MATRIXBANDPART_H__ - -#include "OpChef.h" - -class MatrixBandPartChef final : public OpChef -{ -public: - explicit MatrixBandPartChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_CUSTOM; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - - flatbuffers::Offset<flatbuffers::Vector<uint8_t>> - custom_value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MatrixBandPartChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MATRIXBANDPART_H__ diff --git a/compiler/tflchef/core/src/Data/Constant.h b/compiler/tflchef/core/src/Data/Constant.h new file mode 100644 index 000000000..ebe1f3d93 --- /dev/null +++ b/compiler/tflchef/core/src/Data/Constant.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __CONSTANT_FILLER_H__ +#define __CONSTANT_FILLER_H__ + +#include "DataChef.h" +#include "LexicalCast.h" + +template <typename T> class ConstantDataChef final : public DataChef +{ +public: + ConstantDataChef(const T &value) : _value{value} + { + // DO NOTHING + } + +public: + std::vector<uint8_t> generate(int32_t count) const override + { + std::vector<uint8_t> res; + + for (uint32_t n = 0; n < count; ++n) + { + const uint8_t *arr = reinterpret_cast<const uint8_t *>(&_value); + + for (uint32_t b = 0; b < sizeof(T); ++b) + { + res.emplace_back(arr[b]); + } + } + + return res; + } + +private: + T _value; +}; + +template <typename T> struct ConstantDataChefFactory : public DataChefFactory +{ + std::unique_ptr<DataChef> create(const Arguments &args) const + { + auto const value = to_number<T>(args.value(0)); + return std::unique_ptr<DataChef>{new ConstantDataChef<T>{value}}; + } +}; + +#endif // __CONSTANT_FILLER_H__ diff --git a/compiler/tflchef/core/src/Data/Explicit.h b/compiler/tflchef/core/src/Data/Explicit.h new file mode 100644 index 000000000..f4175f485 --- /dev/null +++ b/compiler/tflchef/core/src/Data/Explicit.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __EXPLICIT_FILLER_H__ +#define __EXPLICIT_FILLER_H__ + +#include "DataChef.h" +#include "LexicalCast.h" + +#include <vector> + +/** + * @brief Return the identity of arithmetic addition + */ +template <typename T> T zero(void); + +template <> int zero(void) { return 0; } + +template <typename T> class ExplicitDataChef final : public DataChef +{ +public: + ExplicitDataChef() + { + // DO NOTHING + } + +public: + std::vector<uint8_t> generate(int32_t count) const override + { + std::vector<uint8_t> res; + + for (uint32_t n = 0; n < count; ++n) + { + T const value = (n < _values.size()) ? _values.at(n) : zero<T>(); + const uint8_t *arr = reinterpret_cast<const uint8_t *>(&value); + + for (uint32_t b = 0; b < sizeof(T); ++b) + { + res.emplace_back(arr[b]); + } + } + + return res; + } + +public: + void insert(const T &value) { _values.emplace_back(value); } + +private: + std::vector<T> _values; +}; + +template <typename T> struct ExplicitDataChefFactory : public DataChefFactory +{ + std::unique_ptr<DataChef> create(const Arguments &args) const + { + std::unique_ptr<ExplicitDataChef<T>> res{new ExplicitDataChef<T>}; + + for (uint32_t n = 0; n < args.count(); ++n) + { + auto const value = to_number<T>(args.value(n)); + res->insert(value); + } + + return std::move(res); + } +}; + +#endif // __EXPLICIT_FILLER_H__ diff --git a/compiler/tflchef/core/src/Data/Gaussian.cpp b/compiler/tflchef/core/src/Data/Gaussian.cpp new file mode 100644 index 000000000..411f7b048 --- /dev/null +++ b/compiler/tflchef/core/src/Data/Gaussian.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 "Gaussian.h" +#include "LexicalCast.h" + +#include <random> +#include <chrono> + +#include <cassert> +#include <stdexcept> + +std::vector<uint8_t> GaussianFloat32DataChef::generate(int32_t count) const +{ + // TODO Support seed value override + int seed = std::chrono::system_clock::now().time_since_epoch().count(); + + std::minstd_rand rand{seed}; + std::normal_distribution<float> dist{_mean, _stddev}; + + std::vector<uint8_t> res; + + for (uint32_t n = 0; n < count; ++n) + { + auto const value = dist(rand); + auto const arr = reinterpret_cast<const uint8_t *>(&value); + + for (uint32_t b = 0; b < sizeof(float); ++b) + { + res.emplace_back(arr[b]); + } + } + + return res; +} + +std::unique_ptr<DataChef> GaussianFloat32DataChefFactory::create(const Arguments &args) const +{ + if (args.count() != 2) + { + throw std::runtime_error{"invalid argument count: two arguments (mean/stddev) are expected"}; + } + + auto const mean = to_number<float>(args.value(0)); + auto const stddev = to_number<float>(args.value(1)); + + return std::unique_ptr<DataChef>{new GaussianFloat32DataChef{mean, stddev}}; +} diff --git a/compiler/tflchef/tflite/src/Op/Softmax.h b/compiler/tflchef/core/src/Data/Gaussian.h index cf168bdd9..588d3e1cf 100644 --- a/compiler/tflchef/tflite/src/Op/Softmax.h +++ b/compiler/tflchef/core/src/Data/Gaussian.h @@ -14,26 +14,33 @@ * limitations under the License. */ -#ifndef __TFLITE_OP_SOFTMAX_H__ -#define __TFLITE_OP_SOFTMAX_H__ +#ifndef __GAUSSIAN_FILLER_H__ +#define __GAUSSIAN_FILLER_H__ -#include "TFliteOpChef.h" - -namespace tflchef -{ +#include "DataChef.h" /** - * @brief tflchef operator builder for Softmax + * @brief Generate a sequence of random values according to the gaussian(=normal) distribution */ -class TFliteOpSoftmax : public TFliteOpChef +class GaussianFloat32DataChef final : public DataChef { public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; + GaussianFloat32DataChef(float mean, float stddev) : _mean{mean}, _stddev{stddev} + { + // DO NOTHING + } + +public: + std::vector<uint8_t> generate(int32_t count) const override; + +private: + float _mean; + float _stddev; }; -} // namespace tflchef +struct GaussianFloat32DataChefFactory : public DataChefFactory +{ + std::unique_ptr<DataChef> create(const Arguments &args) const; +}; -#endif // __TFLITE_OP_SOFTMAX_H__ +#endif // __GAUSSIAN_FILLER_H__ diff --git a/compiler/tflchef/core/src/DataChef.def b/compiler/tflchef/core/src/DataChef.def new file mode 100644 index 000000000..9e894979b --- /dev/null +++ b/compiler/tflchef/core/src/DataChef.def @@ -0,0 +1,9 @@ +#ifndef DATA_CHEF +#error "Define DATA_CHEF first" +#endif // DATA_CHEF + +// DATA_CHEF(TYPE, NAME, FACTORY_CLASS) +// "TYPE" SHOULD BE an enum tag of tflchef::TensorType +DATA_CHEF(FLOAT32, constant, ConstantDataChefFactory<float>) +DATA_CHEF(INT32, explicit, ExplicitDataChefFactory<int>) +DATA_CHEF(FLOAT32, gaussian, GaussianFloat32DataChefFactory) diff --git a/compiler/tflchef/core/src/DataChef.h b/compiler/tflchef/core/src/DataChef.h new file mode 100644 index 000000000..d0571028a --- /dev/null +++ b/compiler/tflchef/core/src/DataChef.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __DATA_CHEF_H__ +#define __DATA_CHEF_H__ + +#include "Arguments.h" + +#include <cstdint> +#include <memory> +#include <vector> + +using Data = std::vector<uint8_t>; + +/** + * @brief Data Generator + */ +struct DataChef +{ + virtual ~DataChef() = default; + + // TODO Allow users to query the type of elements that this DataChef generates + + /** + * @brief Generate a sequence of 'count' elements as a byte sequence + * + * Let D be the return value of generate(N). + * Then, D.size() == N * sizeof(T) where T is the element type. + */ + virtual Data generate(int32_t count) const = 0; +}; + +/** + * @brief Data Generator Factory + */ +struct DataChefFactory +{ + virtual ~DataChefFactory() = default; + + virtual std::unique_ptr<DataChef> create(const Arguments &args) const = 0; +}; + +#endif // __DATA_CHEF_H__ diff --git a/compiler/tflchef/tflite/src/FillerHelper.h b/compiler/tflchef/core/src/DataChefs.h index 053a5c18a..2310ae89d 100644 --- a/compiler/tflchef/tflite/src/FillerHelper.h +++ b/compiler/tflchef/core/src/DataChefs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,18 +14,11 @@ * limitations under the License. */ -#ifndef __FILLER_HELPER_H__ -#define __FILLER_HELPER_H__ +#ifndef __DATA_CHEFS_H__ +#define __DATA_CHEFS_H__ -#include "TFliteImport.h" +#include "Data/Constant.h" +#include "Data/Explicit.h" +#include "Data/Gaussian.h" -#include <mio/tflite/schema_generated.h> - -namespace tflchef -{ - -void fill_tensor_to_import(int32_t idx, TFliteImport *import); - -} // namespace tflchef - -#endif // __FILLER_HELPER_H__ +#endif // __DATA_CHEFS_H__ diff --git a/compiler/tflchef/core/src/Dataset.h b/compiler/tflchef/core/src/Dataset.h new file mode 100644 index 000000000..9d5c7a43f --- /dev/null +++ b/compiler/tflchef/core/src/Dataset.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __DATASET_H__ +#define __DATASET_H__ + +#include <vector> + +template <typename T> class Dataset +{ +public: + Dataset(const std::vector<T> &vec) : _vec{vec} + { + // DO NOTHING + } + +public: + Dataset(std::vector<T> &&vec) : _vec{std::move(vec)} + { + // DO NOTHING + } + +public: + template <typename Func> auto map(Func f) const -> Dataset<decltype(f(std::declval<T>()))> + { + using U = decltype(f(std::declval<T>())); + std::vector<U> res; + + for (const auto &elem : _vec) + { + res.emplace_back(f(elem)); + } + + return Dataset<U>(std::move(res)); + } + +public: + const std::vector<T> &vectorize(void) const { return _vec; } + +private: + std::vector<T> _vec; +}; + +#endif // __DATASET_H__ diff --git a/compiler/tflchef/log/include/LoggingContext.h b/compiler/tflchef/core/src/LexicalCast.cpp index 860099482..334729dc4 100644 --- a/compiler/tflchef/log/include/LoggingContext.h +++ b/compiler/tflchef/core/src/LexicalCast.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,22 +14,7 @@ * limitations under the License. */ -#ifndef __TFLCHEF_LOGGING_CONTEXT_H__ -#define __TFLCHEF_LOGGING_CONTEXT_H__ +#include "LexicalCast.h" -#include <hermes.h> - -namespace tflchef -{ - -/** - * @brief Global logging context - */ -struct LoggingContext -{ - static hermes::Context *get(void); -}; - -} // namespace tflchef - -#endif // __TFLCHEF_LOGGING_CONTEXT_H__ +template <> float to_number(const std::string &s) { return std::stof(s); } +template <> int to_number(const std::string &s) { return std::stoi(s); } diff --git a/compiler/tflchef/core/src/Op/Equal.cpp b/compiler/tflchef/core/src/LexicalCast.h index f7a39f03d..4aeccb482 100644 --- a/compiler/tflchef/core/src/Op/Equal.cpp +++ b/compiler/tflchef/core/src/LexicalCast.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,16 +14,19 @@ * limitations under the License. */ -#include "Equal.h" +/** + * @brief This file provides string <-> number cast helpers + */ +#ifndef __LEXICAL_CAST_H__ +#define __LEXICAL_CAST_H__ -flatbuffers::Offset<void> EqualChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::EqualOptionsBuilder options_builder{fbb}; +#include <string> - return options_builder.Finish().Union(); -} +/** + * @brief Return a numeric value that corresponds to a given string + * + * @note This function will throw an exception on casting failure + */ +template <typename Number> Number to_number(const std::string &s); -std::unique_ptr<OpChef> EqualChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new EqualChef{operation}}; -} +#endif // __LEXICAL_CAST_H__ diff --git a/compiler/tflchef/core/src/ModelChef.cpp b/compiler/tflchef/core/src/ModelChef.cpp index 164011d68..95886874f 100644 --- a/compiler/tflchef/core/src/ModelChef.cpp +++ b/compiler/tflchef/core/src/ModelChef.cpp @@ -15,20 +15,17 @@ */ #include "tflchef/ModelChef.h" -#include <souschef/RangedArguments.h> -#include <souschef/Registry.h> +#include "Arguments.h" #include "Convert.h" -#include <souschef/DataChefs.h> +#include "DataChef.h" +#include "DataChefs.h" #include "OpChef.h" #include "OpChefs.h" -#include <souschef/Dataset.h> -#include <souschef/Dims.h> - -#include "Log.h" +#include "Dataset.h" #include <iterator> #include <map> @@ -39,10 +36,80 @@ #include <fstream> #include <iostream> #include <numeric> -#include <sstream> #include <stdexcept> -using namespace souschef; +namespace +{ + +template <typename InputIt> class RangedArguments : public Arguments +{ +public: + RangedArguments(InputIt beg, InputIt end) : _beg{beg}, _end{end} + { + // DO NOTHING + } + +public: + uint32_t count(void) const override { return _end - _beg; } + +public: + const std::string &value(uint32_t n) const override { return *(_beg + n); } + +private: + InputIt _beg; + InputIt _end; +}; + +template <typename InputIt> RangedArguments<InputIt> ranged_arguments(InputIt beg, InputIt end) +{ + return RangedArguments<InputIt>{beg, end}; +} + +} // namespace + +namespace +{ + +template <typename T> std::vector<T> as_vector(const ::google::protobuf::RepeatedPtrField<T> &field) +{ + std::vector<T> res; + for (const auto &elem : field) + { + res.emplace_back(elem); + } + return res; +} + +template <typename T> Dataset<T> as_dataset(const ::google::protobuf::RepeatedPtrField<T> &field) +{ + return Dataset<T>(as_vector<T>(field)); +} + +} // namespace + +namespace +{ + +template <typename T> using Dims = std::vector<T>; + +Dims<int32_t> as_dims(const tflchef::TensorShape &shape) +{ + std::vector<int32_t> res; + + for (auto &dim : shape.dim()) + { + res.emplace_back(static_cast<int32_t>(dim)); + } + + return res; +} + +int32_t element_count(const Dims<int32_t> &dims) +{ + return std::accumulate(dims.begin(), dims.end(), 1, std::multiplies<int32_t>()); +} + +} // namespace namespace { @@ -79,6 +146,20 @@ private: namespace { +template <typename T> class Registry +{ +public: + void add(const std::string &name, std::unique_ptr<T> &&entry) + { + _content[name] = std::move(entry); + } + + const T &lookup(const std::string &name) const { return *(_content.at(name)); } + +private: + std::map<std::string, std::unique_ptr<T>> _content; +}; + struct DataChefRegistry final : public Registry<DataChefFactory> { }; @@ -86,23 +167,14 @@ struct DataChefRegistry final : public Registry<DataChefFactory> DataChefRegistry &data_chef_registry(const tflchef::TensorType &type) { static DataChefRegistry s32; - static DataChefRegistry s64; static DataChefRegistry fp32; - static DataChefRegistry u8; - static DataChefRegistry boolean; switch (type) { case tflchef::INT32: return s32; - case tflchef::INT64: - return s64; case tflchef::FLOAT32: return fp32; - case tflchef::UINT8: - return u8; - case tflchef::BOOL: - return boolean; default: break; } @@ -120,160 +192,93 @@ OpChefRegistry &op_chef_registry(void) return registry; } -/// @brief This will prepare a map of unique builtin codes in the model recipe -std::map<tflite::BuiltinOperator, int32_t> -gather_builtincode_map(const ::tflchef::ModelRecipe &model_recipe) +// @brief This will prepare a set of unique operator codes in the mode recipe +std::set<tflite::BuiltinOperator> gather_opcode_set(const ::tflchef::ModelRecipe &model_recipe) { - // Key and value of the map are BuiltinOperator and operator version - std::map<tflite::BuiltinOperator, int32_t> builtin_map; - + std::set<tflite::BuiltinOperator> opcode_set; for (const auto &operation : model_recipe.operation()) { auto op_chef = op_chef_registry().lookup(operation.type()).create(&operation); - if (op_chef->code() == tflite::BuiltinOperator_CUSTOM) - continue; - - // Various operation version is unified as the highest version among them - if (builtin_map.find(op_chef->code()) == builtin_map.end() || - builtin_map[op_chef->code()] < operation.version()) - builtin_map[op_chef->code()] = operation.version(); + opcode_set.insert(op_chef->code()); } - - // Add ops used in Graphs(subgraphs) - for (int g = 0; g < model_recipe.graph_size(); ++g) - { - const auto &graph = model_recipe.graph(g); - for (const auto &operation : graph.operation()) - { - auto op_chef = op_chef_registry().lookup(operation.type()).create(&operation); - if (op_chef->code() == tflite::BuiltinOperator_CUSTOM) - continue; - - // Various operation version is unified as the highest version among them - if (builtin_map.find(op_chef->code()) == builtin_map.end() || - builtin_map[op_chef->code()] < operation.version()) - builtin_map[op_chef->code()] = operation.version(); - } - } - - return builtin_map; -} - -/// @brief This will prepare a set of unique custom codes in the mode recipe -std::set<std::string> gather_customcode_set(const ::tflchef::ModelRecipe &model_recipe) -{ - std::set<std::string> customcode_set; - for (const auto &operation : model_recipe.operation()) - { - auto op_chef = op_chef_registry().lookup(operation.type()).create(&operation); - if (op_chef->code() == tflite::BuiltinOperator_CUSTOM) - customcode_set.insert(operation.type()); - } - - // Add ops used in Graphs(subgraphs) - for (int g = 0; g < model_recipe.graph_size(); ++g) - { - const auto &graph = model_recipe.graph(g); - for (const auto &operation : graph.operation()) - { - auto op_chef = op_chef_registry().lookup(operation.type()).create(&operation); - if (op_chef->code() == tflite::BuiltinOperator_CUSTOM) - customcode_set.insert(operation.type()); - } - } - - return customcode_set; + return opcode_set; } } // namespace -namespace +namespace tflchef { -struct CookParams +/** + * @brief Generate a (in-memory) TensorFlow Lite model from a given model recipe + */ +GeneratedModel cook(const ::tflchef::ModelRecipe &model_recipe) { - std::vector<flatbuffers::Offset<::tflite::Buffer>> &buffer_vec; - std::vector<flatbuffers::Offset<::tflite::OperatorCode>> &code_vec; - std::vector<flatbuffers::Offset<::tflite::SubGraph>> &subgraph_vec; - std::unique_ptr<flatbuffers::FlatBufferBuilder> &flatbuffer_builder; - std::map<tflite::BuiltinOperator, int32_t> &builtin_code_map; - std::string noname; -}; +// Initialize Op Chef Registry +#define OP_CHEF(NAME, FACTORY_CLASS) \ + op_chef_registry().add(#NAME, std::unique_ptr<FACTORY_CLASS>(new FACTORY_CLASS())); +#include "OpChef.def" +#undef OP_CHEF -template <typename T> void cook_graph(const T &graph, CookParams &cp) -{ - LOGGER(l); +// Initialize Data Chef Registry +#define DATA_CHEF(TYPE, NAME, FACTORY_CLASS) \ + data_chef_registry(::tflchef::TYPE) \ + .add(#NAME, std::unique_ptr<FACTORY_CLASS>(new FACTORY_CLASS())); +#include "DataChef.def" +#undef DATA_CHEF - std::vector<flatbuffers::Offset<::tflite::Buffer>> &buffer_vec = cp.buffer_vec; - std::vector<flatbuffers::Offset<::tflite::OperatorCode>> &code_vec = cp.code_vec; - std::vector<flatbuffers::Offset<::tflite::SubGraph>> &subgraph_vec = cp.subgraph_vec; - std::unique_ptr<flatbuffers::FlatBufferBuilder> &flatbuffer_builder = cp.flatbuffer_builder; - std::map<tflite::BuiltinOperator, int32_t> &builtin_code_map = cp.builtin_code_map; + // Tensor Name -> Tensor ID mapping + std::map<std::string, int32_t> symbol_table; + + auto lookup = [&symbol_table](const std::string &name) { return symbol_table.at(name); }; + + // + // Create FlatBufferBuilder + // + auto flatbuffer_builder = + std::unique_ptr<flatbuffers::FlatBufferBuilder>(new flatbuffers::FlatBufferBuilder(1024)); // Operand-related + std::vector<flatbuffers::Offset<::tflite::Buffer>> buffer_vec; std::vector<flatbuffers::Offset<::tflite::Tensor>> tensor_vec; // Operation-related + std::vector<flatbuffers::Offset<::tflite::OperatorCode>> code_vec; std::vector<flatbuffers::Offset<::tflite::Operator>> operator_vec; - // default name for graph - std::string graph_name = cp.noname; - if (graph.has_name()) - graph_name = graph.name(); - - // Tensor Name -> Tensor ID mapping (per Graph) - std::map<std::string, int32_t> symbol_table; - - auto lookup = [&symbol_table, &graph_name](const std::string &name) { - if (symbol_table.find(name) != symbol_table.end()) - return symbol_table.at(name); - else if (name == "") - return -1; // -1 in TFLite means that optional input tensor is empty. - else - { - std::string msg = "tflchef : input not found in " + graph_name + " graph"; - throw std::runtime_error(msg.c_str()); - } - }; - - int32_t buffer_start = buffer_vec.size(); - int32_t buffer_index = 0; - - // Create buffer(s) 1~n(I) for input(s) - const auto size_input = graph.input_size(); - for (int ci = 0; ci < size_input; ++ci) + // Create OperatorCode + std::set<tflite::BuiltinOperator> opcode_set = gather_opcode_set(model_recipe); + for (auto opcode : opcode_set) { - tflite::BufferBuilder buffer_builder{*flatbuffer_builder}; - buffer_vec.emplace_back(buffer_builder.Finish()); + tflite::OperatorCodeBuilder code_builder{*flatbuffer_builder}; + code_builder.add_builtin_code(opcode); + auto code = code_builder.Finish(); + // Update OperatorCode vector + code_vec.emplace_back(code); } - // Create buffer(s) n(I)+1~n(I)+n(O) for output(s) - const auto size_output = graph.output_size(); - for (int co = 0; co < size_output; ++co) + + // Create an Empty Buffer + // + // Buffer 0 SHOULD be an empty buffer in TensorFlow Lite model file + // (Please refer to the comment for Tensor.buffer field in schema) { tflite::BufferBuilder buffer_builder{*flatbuffer_builder}; buffer_vec.emplace_back(buffer_builder.Finish()); } - auto input_names = as_dataset(graph.input()).vectorize(); - auto output_names = as_dataset(graph.output()).vectorize(); - - for (const auto &operand : graph.operand()) + for (const auto &operand : model_recipe.operand()) { assert(operand.has_name()); assert(operand.has_type()); + assert(operand.has_shape()); - flatbuffers::Offset<flatbuffers::Vector<int32_t>> shape; - std::vector<int32_t> dims; - if (operand.has_shape()) - { - dims = as_dims(operand.shape()); - shape = flatbuffer_builder->CreateVector(dims); - } + std::vector<int32_t> dims = as_dims(operand.shape()); + auto shape = flatbuffer_builder->CreateVector(dims); auto name = flatbuffer_builder->CreateString(operand.name()); - buffer_index = 0; + int32_t buffer_index = 0; // Create Buffer if filler is specified if (operand.has_filler()) @@ -288,8 +293,7 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) assert(chef != nullptr); // Create Data - int32_t count = (element_count(dims) > 0) ? element_count(dims) : filler.arg_size(); - auto data_vec = chef->generate(count); + auto data_vec = chef->generate(element_count(dims)); auto data = flatbuffer_builder->CreateVector(data_vec); // Create Buffer @@ -301,40 +305,6 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) buffer_index = buffer_vec.size(); buffer_vec.emplace_back(buffer); } - else - { - // if this is input or output, assign to that buffer_index - int idx = 0; - for (auto it = input_names.begin(); it != input_names.end(); ++it, ++idx) - { - if (*it == operand.name()) - { - buffer_index = buffer_start + idx; - break; - } - } - if (buffer_index == 0) - { - idx = 0; - for (auto it = output_names.begin(); it != output_names.end(); ++it, ++idx) - { - if (*it == operand.name()) - { - buffer_index = buffer_start + size_input + idx; - break; - } - } - } - if (buffer_index == 0) - { - // we couldn't find the buffer; create an empty buffer for this tensor - buffer_index = buffer_vec.size(); - - tflite::BufferBuilder buffer_builder{*flatbuffer_builder}; - buffer_vec.emplace_back(buffer_builder.Finish()); - } - } - assert(buffer_index != 0); flatbuffers::Offset<tflite::QuantizationParameters> quant_index; @@ -351,13 +321,13 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) std::vector<int64_t> quant_zero_point_vec(quant.zero_point_size()); for (uint32_t i = 0; i < quant.max_size(); ++i) - quant_max_vec.at(i) = quant.max(i); + quant_max_vec.push_back(quant.max(i)); for (uint32_t i = 0; i < quant.min_size(); ++i) - quant_min_vec.at(i) = quant.min(i); + quant_max_vec.push_back(quant.min(i)); for (uint32_t i = 0; i < quant.scale_size(); ++i) - quant_scale_vec.at(i) = quant.scale(i); + quant_max_vec.push_back(quant.scale(i)); for (uint32_t i = 0; i < quant.zero_point_size(); ++i) - quant_zero_point_vec.at(i) = quant.zero_point(i); + quant_max_vec.push_back(quant.zero_point(i)); auto quant_max = flatbuffer_builder->CreateVector(quant_max_vec); auto quant_min = flatbuffer_builder->CreateVector(quant_min_vec); @@ -370,59 +340,11 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) quant_builder.add_min(quant_min); quant_builder.add_scale(quant_scale); quant_builder.add_zero_point(quant_zero_point); - quant_builder.add_quantized_dimension(quant.quantized_dimension()); // Update QuantizationParameters Index quant_index = quant_builder.Finish(); } - flatbuffers::Offset<tflite::SparsityParameters> sparsity_index; - - if (operand.has_sparsity()) - { - const auto &sparsity = operand.sparsity(); - - // Create traversal order - std::vector<int> traversal_order_vec{sparsity.traversal_order().dim().begin(), - sparsity.traversal_order().dim().end()}; - auto traversal_order = flatbuffer_builder->CreateVector(traversal_order_vec); - - // Create block map - std::vector<int> block_map_vec{sparsity.block_map().dim().begin(), - sparsity.block_map().dim().end()}; - auto block_map = flatbuffer_builder->CreateVector(block_map_vec); - - // Create dimension metadata - std::vector<flatbuffers::Offset<tflite::DimensionMetadata>> dim_metadata_vec; - auto recipe_dim_metadata = sparsity.dim_metadata(); - for (const auto &dm : recipe_dim_metadata) - { - // Create array segments - auto tflite_array_segments = - as_tflite_sparse_index_vec(*flatbuffer_builder, dm.array_segments()); - - // Create array indices - auto tflite_array_indices = - as_tflite_sparse_index_vec(*flatbuffer_builder, dm.array_indices()); - - auto tflite_dim_metadata_builder = tflite::DimensionMetadataBuilder{*flatbuffer_builder}; - tflite_dim_metadata_builder.add_format(as_tflite_dimensiontype(dm.format())); - tflite_dim_metadata_builder.add_dense_size(dm.dense_size()); - tflite_dim_metadata_builder.add_array_segments(tflite_array_segments); - tflite_dim_metadata_builder.add_array_segments_type( - as_tflite_sparse_idx_vec_type(dm.array_segments().type())); - tflite_dim_metadata_builder.add_array_indices(tflite_array_indices); - tflite_dim_metadata_builder.add_array_indices_type( - as_tflite_sparse_idx_vec_type(dm.array_indices().type())); - auto tflite_dim_metadata = tflite_dim_metadata_builder.Finish(); - dim_metadata_vec.emplace_back(tflite_dim_metadata); - } - auto dim_metadata = flatbuffer_builder->CreateVector(dim_metadata_vec); - - sparsity_index = tflite::CreateSparsityParameters(*flatbuffer_builder, traversal_order, - block_map, dim_metadata); - } - // Create Tensor tflite::TensorBuilder tensor_builder{*flatbuffer_builder}; @@ -430,10 +352,8 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) tensor_builder.add_type(as_tflite_tensortype(operand.type())); tensor_builder.add_buffer(buffer_index); tensor_builder.add_name(name); - tensor_builder.add_is_variable(operand.is_variable()); if (operand.has_quant()) tensor_builder.add_quantization(quant_index); - tensor_builder.add_sparsity(sparsity_index); // Append! tensor_vec.emplace_back(tensor_builder.Finish()); @@ -442,13 +362,11 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) int32_t tensor_index = symbol_table.size(); const auto &tensor_name = operand.name(); - INFO(l) << "Symbol [" << tensor_name << "] = Tensor " << tensor_index << std::endl; - symbol_table[tensor_name] = tensor_index; } // Create Operator - for (const auto &operation : graph.operation()) + for (const auto &operation : model_recipe.operation()) { assert(operation.has_type()); @@ -465,39 +383,37 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) // Create Option auto options = op_chef->value(*flatbuffer_builder); - // Create Custom option - auto circle_custom_options = op_chef->custom_value(*flatbuffer_builder); - // Create Operator tflite::OperatorBuilder op_builder{*flatbuffer_builder}; - // Get operator code index from builtin_code_set with assumption, order of - // builtin_code_set is same as that of code_vec - auto op_it = builtin_code_map.find(op_chef->code()); - assert(op_it != builtin_code_map.end()); - uint32_t opcode_index = std::distance(builtin_code_map.begin(), op_it); + // Get operator code index from opcode_set with assumption, order of + // opcode_set is same as that of code_vec + auto op_it = opcode_set.find(op_chef->code()); + assert(op_it != opcode_set.end()); + uint32_t opcode_index = std::distance(opcode_set.begin(), op_it); op_builder.add_opcode_index(opcode_index); op_builder.add_inputs(inputs); op_builder.add_outputs(outputs); op_builder.add_builtin_options_type(op_chef->type()); op_builder.add_builtin_options(options); - op_builder.add_custom_options(circle_custom_options); - op_builder.add_custom_options_format(tflite::CustomOptionsFormat_FLEXBUFFERS); + // Append Operator operator_vec.emplace_back(op_builder.Finish()); } // Create network input/output vector - std::vector<int32_t> input_vec = as_dataset(graph.input()).map(lookup).vectorize(); - std::vector<int32_t> output_vec = as_dataset(graph.output()).map(lookup).vectorize(); + std::vector<int32_t> input_vec = as_dataset(model_recipe.input()).map(lookup).vectorize(); + std::vector<int32_t> output_vec = as_dataset(model_recipe.output()).map(lookup).vectorize(); // Create "SubGraph" arguments auto tensors = flatbuffer_builder->CreateVector(tensor_vec); auto inputs = flatbuffer_builder->CreateVector(input_vec); auto outputs = flatbuffer_builder->CreateVector(output_vec); auto operators = flatbuffer_builder->CreateVector(operator_vec); - auto name = flatbuffer_builder->CreateString(graph_name); + + // Create "SubGraph" + std::vector<flatbuffers::Offset<::tflite::SubGraph>> subgraph_vec; tflite::SubGraphBuilder subgraph_builder{*flatbuffer_builder}; @@ -505,109 +421,8 @@ template <typename T> void cook_graph(const T &graph, CookParams &cp) subgraph_builder.add_inputs(inputs); subgraph_builder.add_outputs(outputs); subgraph_builder.add_operators(operators); - subgraph_builder.add_name(name); subgraph_vec.emplace_back(subgraph_builder.Finish()); -} - -} // namespace - -namespace tflchef -{ - -/** - * @brief Generate a (in-memory) TensorFlow Lite model from a given model recipe - */ -GeneratedModel cook(const ::tflchef::ModelRecipe &model_recipe) -{ -// Initialize Op Chef Registry -#define OP_CHEF(NAME, FACTORY_CLASS) \ - op_chef_registry().add(#NAME, std::unique_ptr<FACTORY_CLASS>(new FACTORY_CLASS())); -#include "OpChef.def" -#undef OP_CHEF - -// Initialize Data Chef Registry -#define DATA_CHEF(TYPE, NAME, FACTORY_CLASS) \ - data_chef_registry(::tflchef::TYPE) \ - .add(#NAME, std::unique_ptr<FACTORY_CLASS>(new FACTORY_CLASS())); -#include <souschef/DataChef.def> -#undef DATA_CHEF - - // - // Create FlatBufferBuilder - // - auto flatbuffer_builder = - std::unique_ptr<flatbuffers::FlatBufferBuilder>(new flatbuffers::FlatBufferBuilder(1024)); - - // Operand-related - std::vector<flatbuffers::Offset<::tflite::Buffer>> buffer_vec; - - // Operation-related - std::vector<flatbuffers::Offset<::tflite::OperatorCode>> code_vec; - - // Graphs-related - std::vector<flatbuffers::Offset<::tflite::SubGraph>> subgraph_vec; - - // Create OperatorCode with Builtin Operator - auto builtin_code_map = gather_builtincode_map(model_recipe); - for (auto const &opcode : builtin_code_map) - { - tflite::OperatorCodeBuilder code_builder{*flatbuffer_builder}; - code_builder.add_builtin_code(opcode.first); - code_builder.add_version(opcode.second); - auto code = code_builder.Finish(); - // Update OperatorCode vector - code_vec.emplace_back(code); - } - - // Create OperatorCode with Custom Operator - std::set<std::string> custom_code_set = gather_customcode_set(model_recipe); - if (custom_code_set.size() && - builtin_code_map.find(tflite::BuiltinOperator_CUSTOM) == builtin_code_map.end()) - builtin_code_map[tflite::BuiltinOperator_CUSTOM] = 1; - - for (auto opcode : custom_code_set) - { - auto custom_code = flatbuffer_builder->CreateString(opcode); - tflite::OperatorCodeBuilder code_builder{*flatbuffer_builder}; - code_builder.add_builtin_code(tflite::BuiltinOperator_CUSTOM); - code_builder.add_custom_code(custom_code); - auto code = code_builder.Finish(); - // Update OperatorCode vector - code_vec.emplace_back(code); - } - - // Create an Empty Buffer - // - // Buffer 0 SHOULD be an empty buffer in TensorFlow Lite model file - // (Please refer to the comment for Tensor.buffer field in schema) - { - tflite::BufferBuilder buffer_builder{*flatbuffer_builder}; - buffer_vec.emplace_back(buffer_builder.Finish()); - } - - // - // Create Main graph - // - CookParams cp{buffer_vec, code_vec, subgraph_vec, flatbuffer_builder, builtin_code_map, "main"}; - - cook_graph<::tflchef::ModelRecipe>(model_recipe, cp); - - // - // Create subgraphs if exist - // - for (int g = 0; g < model_recipe.graph_size(); ++g) - { - const auto &graph = model_recipe.graph(g); - - std::ostringstream stringStream; - stringStream << "sub_" << (g + 1); - - CookParams cp{buffer_vec, code_vec, subgraph_vec, - flatbuffer_builder, builtin_code_map, stringStream.str()}; - - cook_graph<::tflchef::Graph>(graph, cp); - } // Create "Model" arguments auto buffers = flatbuffer_builder->CreateVector(buffer_vec); diff --git a/compiler/tflchef/core/src/Op/Abs.cpp b/compiler/tflchef/core/src/Op/Abs.cpp deleted file mode 100644 index dcb27784c..000000000 --- a/compiler/tflchef/core/src/Op/Abs.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Abs.h" -#include "Convert.h" - -flatbuffers::Offset<void> AbsChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::AbsOptionsBuilder abs_options_builder{fbb}; - - return abs_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> AbsChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new AbsChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Abs.h b/compiler/tflchef/core/src/Op/Abs.h deleted file mode 100644 index 5b694c6b6..000000000 --- a/compiler/tflchef/core/src/Op/Abs.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ABS_H__ -#define __OP_ABS_H__ - -#include "OpChef.h" - -class AbsChef final : public OpChef -{ -public: - explicit AbsChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ABS; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_AbsOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct AbsChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ABS_H__ diff --git a/compiler/tflchef/core/src/Op/Add.cpp b/compiler/tflchef/core/src/Op/Add.cpp deleted file mode 100644 index 8679ba35e..000000000 --- a/compiler/tflchef/core/src/Op/Add.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Add.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> AddChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_add_options()); - - auto tflite_activation = as_tflite_activation(operation.add_options().activation()); - - tflite::AddOptionsBuilder add_options_builder{fbb}; - add_options_builder.add_fused_activation_function(tflite_activation); - - return add_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> AddChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new AddChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Add.h b/compiler/tflchef/core/src/Op/Add.h deleted file mode 100644 index 29ddb9470..000000000 --- a/compiler/tflchef/core/src/Op/Add.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ADD_H__ -#define __OP_ADD_H__ - -#include "OpChef.h" - -class AddChef final : public OpChef -{ -public: - explicit AddChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ADD; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_AddOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct AddChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ADD_H__ diff --git a/compiler/tflchef/core/src/Op/AddN.cpp b/compiler/tflchef/core/src/Op/AddN.cpp deleted file mode 100644 index 2ac02d219..000000000 --- a/compiler/tflchef/core/src/Op/AddN.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "AddN.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> AddNChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::AddNOptionsBuilder add_n_options_builder{fbb}; - - return add_n_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> AddNChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new AddNChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/AddN.h b/compiler/tflchef/core/src/Op/AddN.h deleted file mode 100644 index 44dcc63ef..000000000 --- a/compiler/tflchef/core/src/Op/AddN.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ADD_N_H__ -#define __OP_ADD_N_H__ - -#include "OpChef.h" - -class AddNChef final : public OpChef -{ -public: - explicit AddNChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ADD_N; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_AddNOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct AddNChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ADD_N_H__ diff --git a/compiler/tflchef/core/src/Op/ArgMax.cpp b/compiler/tflchef/core/src/Op/ArgMax.cpp deleted file mode 100644 index 2c2995da5..000000000 --- a/compiler/tflchef/core/src/Op/ArgMax.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ArgMax.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ArgMaxChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_argmax_options()); - - auto tflite_output_type = as_tflite_tensortype(operation.argmax_options().output_type()); - - tflite::ArgMaxOptionsBuilder argmax_options_builder{fbb}; - argmax_options_builder.add_output_type(tflite_output_type); - - return argmax_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ArgMaxChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ArgMaxChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ArgMax.h b/compiler/tflchef/core/src/Op/ArgMax.h deleted file mode 100644 index 4033e0f6c..000000000 --- a/compiler/tflchef/core/src/Op/ArgMax.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ARGMAX_H__ -#define __OP_ARGMAX_H__ - -#include "OpChef.h" - -class ArgMaxChef final : public OpChef -{ -public: - explicit ArgMaxChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ARG_MAX; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ArgMaxOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ArgMaxChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ARGMAX_H__ diff --git a/compiler/tflchef/core/src/Op/ArgMin.cpp b/compiler/tflchef/core/src/Op/ArgMin.cpp deleted file mode 100644 index b599270b0..000000000 --- a/compiler/tflchef/core/src/Op/ArgMin.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ArgMin.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ArgMinChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_argmin_options()); - - auto tflite_output_type = as_tflite_tensortype(operation.argmin_options().output_type()); - - tflite::ArgMinOptionsBuilder argmin_options_builder{fbb}; - argmin_options_builder.add_output_type(tflite_output_type); - - return argmin_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ArgMinChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ArgMinChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ArgMin.h b/compiler/tflchef/core/src/Op/ArgMin.h deleted file mode 100644 index 222039f91..000000000 --- a/compiler/tflchef/core/src/Op/ArgMin.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ARGMIN_H__ -#define __OP_ARGMIN_H__ - -#include "OpChef.h" - -class ArgMinChef final : public OpChef -{ -public: - explicit ArgMinChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ARG_MIN; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ArgMinOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ArgMinChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ARGMIN_H__ diff --git a/compiler/tflchef/core/src/Op/BatchMatMul.cpp b/compiler/tflchef/core/src/Op/BatchMatMul.cpp deleted file mode 100644 index 7722bcc5e..000000000 --- a/compiler/tflchef/core/src/Op/BatchMatMul.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "BatchMatMul.h" - -flatbuffers::Offset<void> BatchMatMulChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_batch_matmul_options()); - - tflite::BatchMatMulOptionsBuilder batch_matmul_options_options_builder{fbb}; - batch_matmul_options_options_builder.add_adj_x(operation.batch_matmul_options().adj_x()); - batch_matmul_options_options_builder.add_adj_y(operation.batch_matmul_options().adj_y()); - - return batch_matmul_options_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> BatchMatMulChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new BatchMatMulChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/BatchMatMul.h b/compiler/tflchef/core/src/Op/BatchMatMul.h deleted file mode 100644 index eaf943cb0..000000000 --- a/compiler/tflchef/core/src/Op/BatchMatMul.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_BATCH_MATMUL_H__ -#define __OP_BATCH_MATMUL_H__ - -#include "OpChef.h" - -class BatchMatMulChef final : public OpChef -{ -public: - explicit BatchMatMulChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_BATCH_MATMUL; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_BatchMatMulOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct BatchMatMulChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_BATCH_MATMUL_H__ diff --git a/compiler/tflchef/core/src/Op/BatchToSpaceND.cpp b/compiler/tflchef/core/src/Op/BatchToSpaceND.cpp deleted file mode 100644 index 972f93256..000000000 --- a/compiler/tflchef/core/src/Op/BatchToSpaceND.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "BatchToSpaceND.h" - -#include <cassert> - -flatbuffers::Offset<void> BatchToSpaceNDChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::BatchToSpaceNDOptionsBuilder batch_to_space_nd_options_builder{fbb}; - - return batch_to_space_nd_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> BatchToSpaceNDChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new BatchToSpaceNDChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/BatchToSpaceND.h b/compiler/tflchef/core/src/Op/BatchToSpaceND.h deleted file mode 100644 index 6ba1352ab..000000000 --- a/compiler/tflchef/core/src/Op/BatchToSpaceND.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_BATCHTOSPACEND_H__ -#define __OP_BATCHTOSPACEND_H__ - -#include "OpChef.h" - -class BatchToSpaceNDChef final : public OpChef -{ -public: - explicit BatchToSpaceNDChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_BATCH_TO_SPACE_ND; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_BatchToSpaceNDOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct BatchToSpaceNDChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_BATCHTOSPACEND_H__ diff --git a/compiler/tflchef/core/src/Op/Cast.cpp b/compiler/tflchef/core/src/Op/Cast.cpp deleted file mode 100644 index 1a29f9ac4..000000000 --- a/compiler/tflchef/core/src/Op/Cast.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Cast.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> CastChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - if (!operation.has_cast_options()) - return 0; - - auto tflite_in_data_type = as_tflite_tensortype(operation.cast_options().in_data_type()); - auto tflite_out_data_type = as_tflite_tensortype(operation.cast_options().out_data_type()); - - tflite::CastOptionsBuilder cast_options_builder{fbb}; - cast_options_builder.add_in_data_type(tflite_in_data_type); - cast_options_builder.add_out_data_type(tflite_out_data_type); - - return cast_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> CastChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new CastChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Cast.h b/compiler/tflchef/core/src/Op/Cast.h deleted file mode 100644 index 84c8e29e4..000000000 --- a/compiler/tflchef/core/src/Op/Cast.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_CAST_H__ -#define __OP_CAST_H__ - -#include "OpChef.h" - -class CastChef final : public OpChef -{ -public: - explicit CastChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_CAST; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_CastOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct CastChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_CAST_H__ diff --git a/compiler/tflchef/core/src/Op/Ceil.cpp b/compiler/tflchef/core/src/Op/Ceil.cpp deleted file mode 100644 index 3da047727..000000000 --- a/compiler/tflchef/core/src/Op/Ceil.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Ceil.h" - -flatbuffers::Offset<void> CeilChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Ceil. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> CeilChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new CeilChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Ceil.h b/compiler/tflchef/core/src/Op/Ceil.h deleted file mode 100644 index 5a42b7f00..000000000 --- a/compiler/tflchef/core/src/Op/Ceil.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_CEIL_H__ -#define __OP_CEIL_H__ - -#include "OpChef.h" - -class CeilChef final : public OpChef -{ -public: - explicit CeilChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_CEIL; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct CeilChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_CEIL_H__ diff --git a/compiler/tflchef/core/src/Op/Conv2D.cpp b/compiler/tflchef/core/src/Op/Conv2D.cpp index 0b3ef8a6d..d99c53351 100644 --- a/compiler/tflchef/core/src/Op/Conv2D.cpp +++ b/compiler/tflchef/core/src/Op/Conv2D.cpp @@ -25,18 +25,14 @@ flatbuffers::Offset<void> Conv2DChef::value(flatbuffers::FlatBufferBuilder &fbb) assert(operation.has_conv2d_options()); - const auto &conv2d_options = operation.conv2d_options(); - - auto tflite_padding = as_tflite_padding(conv2d_options.padding()); - auto tflite_activation = as_tflite_activation(conv2d_options.activation()); + auto tflite_padding = as_tflite_padding(operation.conv2d_options().padding()); + auto tflite_activation = as_tflite_activation(operation.conv2d_options().activation()); tflite::Conv2DOptionsBuilder conv2d_options_builder{fbb}; conv2d_options_builder.add_padding(tflite_padding); - conv2d_options_builder.add_stride_h(conv2d_options.stride_h()); - conv2d_options_builder.add_stride_w(conv2d_options.stride_w()); + conv2d_options_builder.add_stride_h(operation.conv2d_options().stride_h()); + conv2d_options_builder.add_stride_w(operation.conv2d_options().stride_w()); conv2d_options_builder.add_fused_activation_function(tflite_activation); - conv2d_options_builder.add_dilation_w_factor(conv2d_options.dilation_w_factor()); - conv2d_options_builder.add_dilation_h_factor(conv2d_options.dilation_h_factor()); return conv2d_options_builder.Finish().Union(); } diff --git a/compiler/tflchef/core/src/Op/Cos.cpp b/compiler/tflchef/core/src/Op/Cos.cpp deleted file mode 100644 index 547bee1a9..000000000 --- a/compiler/tflchef/core/src/Op/Cos.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Cos.h" - -flatbuffers::Offset<void> CosChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::CosOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> CosChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new CosChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Cos.h b/compiler/tflchef/core/src/Op/Cos.h deleted file mode 100644 index 9bf8cbeab..000000000 --- a/compiler/tflchef/core/src/Op/Cos.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_COS_H__ -#define __OP_COS_H__ - -#include "OpChef.h" - -class CosChef final : public OpChef -{ -public: - explicit CosChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_COS; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_CosOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct CosChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_COS_H__ diff --git a/compiler/tflchef/core/src/Op/DepthToSpace.cpp b/compiler/tflchef/core/src/Op/DepthToSpace.cpp deleted file mode 100644 index f0531d98d..000000000 --- a/compiler/tflchef/core/src/Op/DepthToSpace.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "DepthToSpace.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> DepthToSpaceChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_depth_to_space_options()); - - auto options = operation.depth_to_space_options(); - - auto tflite_block_size = options.block_size(); - - tflite::DepthToSpaceOptionsBuilder options_builder{fbb}; - - options_builder.add_block_size(tflite_block_size); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> DepthToSpaceChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new DepthToSpaceChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/DepthToSpace.h b/compiler/tflchef/core/src/Op/DepthToSpace.h deleted file mode 100644 index 32cb24211..000000000 --- a/compiler/tflchef/core/src/Op/DepthToSpace.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_DEPTHTOSPACE_H__ -#define __OP_DEPTHTOSPACE_H__ - -#include "OpChef.h" - -class DepthToSpaceChef final : public OpChef -{ -public: - explicit DepthToSpaceChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_DEPTH_TO_SPACE; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_DepthToSpaceOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct DepthToSpaceChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_DEPTHTOSPACE_H__ diff --git a/compiler/tflchef/core/src/Op/DepthwiseConv2D.cpp b/compiler/tflchef/core/src/Op/DepthwiseConv2D.cpp index 5da5b63e4..e04cf50ff 100644 --- a/compiler/tflchef/core/src/Op/DepthwiseConv2D.cpp +++ b/compiler/tflchef/core/src/Op/DepthwiseConv2D.cpp @@ -36,8 +36,6 @@ flatbuffers::Offset<void> DepthwiseConv2DChef::value(flatbuffers::FlatBufferBuil options_builder.add_stride_h(options.stride_h()); options_builder.add_depth_multiplier(options.depth_multiplier()); options_builder.add_fused_activation_function(tflite_activation); - options_builder.add_dilation_w_factor(options.dilation_w_factor()); - options_builder.add_dilation_h_factor(options.dilation_h_factor()); return options_builder.Finish().Union(); } diff --git a/compiler/tflchef/core/src/Op/Dequantize.cpp b/compiler/tflchef/core/src/Op/Dequantize.cpp deleted file mode 100644 index 761d7f99e..000000000 --- a/compiler/tflchef/core/src/Op/Dequantize.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Dequantize.h" - -flatbuffers::Offset<void> DequantizeChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> DequantizeChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new DequantizeChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Dequantize.h b/compiler/tflchef/core/src/Op/Dequantize.h deleted file mode 100644 index 82580560d..000000000 --- a/compiler/tflchef/core/src/Op/Dequantize.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_DEQUANTIZE_H__ -#define __OP_DEQUANTIZE_H__ - -#include "OpChef.h" - -class DequantizeChef final : public OpChef -{ -public: - explicit DequantizeChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_DEQUANTIZE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct DequantizeChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_DEQUANTIZE_H__ diff --git a/compiler/tflchef/core/src/Op/ELU.h b/compiler/tflchef/core/src/Op/ELU.h deleted file mode 100644 index e164c0071..000000000 --- a/compiler/tflchef/core/src/Op/ELU.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ELU_H__ -#define __OP_ELU_H__ - -#include "OpChef.h" - -class ELUChef final : public OpChef -{ -public: - explicit ELUChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ELU; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ELUChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ELU_H__ diff --git a/compiler/tflchef/core/src/Op/Equal.h b/compiler/tflchef/core/src/Op/Equal.h deleted file mode 100644 index 6e097991d..000000000 --- a/compiler/tflchef/core/src/Op/Equal.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_EQUAL_H__ -#define __OP_EQUAL_H__ - -#include "OpChef.h" - -class EqualChef final : public OpChef -{ -public: - explicit EqualChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_EQUAL; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_EqualOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct EqualChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_EQUAL_H__ diff --git a/compiler/tflchef/core/src/Op/Exp.cpp b/compiler/tflchef/core/src/Op/Exp.cpp deleted file mode 100644 index b3c8d7e73..000000000 --- a/compiler/tflchef/core/src/Op/Exp.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Exp.h" -#include "Convert.h" - -flatbuffers::Offset<void> ExpChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::ExpOptionsBuilder exp_options_builder{fbb}; - - return exp_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ExpChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ExpChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Exp.h b/compiler/tflchef/core/src/Op/Exp.h deleted file mode 100644 index 422a3310f..000000000 --- a/compiler/tflchef/core/src/Op/Exp.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_EXP_H__ -#define __OP_EXP_H__ - -#include "OpChef.h" - -class ExpChef final : public OpChef -{ -public: - explicit ExpChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_EXP; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ExpOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ExpChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ABS_H__ diff --git a/compiler/tflchef/core/src/Op/ExpandDims.cpp b/compiler/tflchef/core/src/Op/ExpandDims.cpp deleted file mode 100644 index c6082811f..000000000 --- a/compiler/tflchef/core/src/Op/ExpandDims.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ExpandDims.h" -#include "Convert.h" - -flatbuffers::Offset<void> ExpandDimsChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::ExpandDimsOptionsBuilder expand_dims_options_builder{fbb}; - - return expand_dims_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ExpandDimsChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ExpandDimsChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ExpandDims.h b/compiler/tflchef/core/src/Op/ExpandDims.h deleted file mode 100644 index 1f4c34a98..000000000 --- a/compiler/tflchef/core/src/Op/ExpandDims.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_EXPAND_DIMS_H__ -#define __OP_EXPAND_DIMS_H__ - -#include "OpChef.h" - -class ExpandDimsChef final : public OpChef -{ -public: - explicit ExpandDimsChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_EXPAND_DIMS; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_ExpandDimsOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ExpandDimsChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_EXPAND_DIMS_H__ diff --git a/compiler/tflchef/core/src/Op/Fill.cpp b/compiler/tflchef/core/src/Op/Fill.cpp deleted file mode 100644 index 4a6829459..000000000 --- a/compiler/tflchef/core/src/Op/Fill.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Fill.h" - -#include <cassert> -#include <vector> - -flatbuffers::Offset<void> FillChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::FillOptionsBuilder options_builder{fbb}; - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> FillChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new FillChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Fill.h b/compiler/tflchef/core/src/Op/Fill.h deleted file mode 100644 index 60f9084c8..000000000 --- a/compiler/tflchef/core/src/Op/Fill.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_FILL_H__ -#define __OP_FILL_H__ - -#include "OpChef.h" - -class FillChef final : public OpChef -{ -public: - explicit FillChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_FILL; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_FillOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct FillChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_FILL_H__ diff --git a/compiler/tflchef/core/src/Op/Floor.cpp b/compiler/tflchef/core/src/Op/Floor.cpp deleted file mode 100644 index 8f6820152..000000000 --- a/compiler/tflchef/core/src/Op/Floor.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Floor.h" - -flatbuffers::Offset<void> FloorChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Floor. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> FloorChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new FloorChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Floor.h b/compiler/tflchef/core/src/Op/Floor.h deleted file mode 100644 index 23385d737..000000000 --- a/compiler/tflchef/core/src/Op/Floor.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_FLOOR_H__ -#define __OP_FLOOR_H__ - -#include "OpChef.h" - -class FloorChef final : public OpChef -{ -public: - explicit FloorChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_FLOOR; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct FloorChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_FLOOR_H__ diff --git a/compiler/tflchef/core/src/Op/FloorDiv.cpp b/compiler/tflchef/core/src/Op/FloorDiv.cpp deleted file mode 100644 index 0d531bede..000000000 --- a/compiler/tflchef/core/src/Op/FloorDiv.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "FloorDiv.h" - -#include <cassert> - -flatbuffers::Offset<void> FloorDivChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::FloorDivOptionsBuilder floor_div_options_builder{fbb}; - return floor_div_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> FloorDivChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new FloorDivChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/FloorDiv.h b/compiler/tflchef/core/src/Op/FloorDiv.h deleted file mode 100644 index 151f24314..000000000 --- a/compiler/tflchef/core/src/Op/FloorDiv.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_FLOORDIV_H__ -#define __OP_FLOORDIV_H__ - -#include "OpChef.h" - -class FloorDivChef final : public OpChef -{ -public: - explicit FloorDivChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_FLOOR_DIV; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_FloorDivOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct FloorDivChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_FLOORDIV_H__ diff --git a/compiler/tflchef/core/src/Op/FloorMod.cpp b/compiler/tflchef/core/src/Op/FloorMod.cpp deleted file mode 100644 index d17795a72..000000000 --- a/compiler/tflchef/core/src/Op/FloorMod.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "FloorMod.h" - -flatbuffers::Offset<void> FloorModChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::FloorModOptionsBuilder options_builder{fbb}; - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> FloorModChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new FloorModChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/FloorMod.h b/compiler/tflchef/core/src/Op/FloorMod.h deleted file mode 100644 index b501f61e0..000000000 --- a/compiler/tflchef/core/src/Op/FloorMod.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_FLOOR_MOD_H__ -#define __OP_FLOOR_MOD_H__ - -#include "OpChef.h" - -class FloorModChef final : public OpChef -{ -public: - explicit FloorModChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_FLOOR_MOD; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_FloorModOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct FloorModChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_FLOOR_MOD_H__ diff --git a/compiler/tflchef/core/src/Op/Gather.cpp b/compiler/tflchef/core/src/Op/Gather.cpp deleted file mode 100644 index 2b62c7be2..000000000 --- a/compiler/tflchef/core/src/Op/Gather.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Gather.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> GatherChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_gather_options()); - - auto options = operation.gather_options(); - - tflite::GatherOptionsBuilder options_builder{fbb}; - - options_builder.add_axis(options.axis()); - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> GatherChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new GatherChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Gather.h b/compiler/tflchef/core/src/Op/Gather.h deleted file mode 100644 index d937178c8..000000000 --- a/compiler/tflchef/core/src/Op/Gather.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_GATHER_H__ -#define __OP_GATHER_H__ - -#include "OpChef.h" - -class GatherChef final : public OpChef -{ -public: - explicit GatherChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_GATHER; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_GatherOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct GatherChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_GATHER_H__ diff --git a/compiler/tflchef/core/src/Op/GatherNd.cpp b/compiler/tflchef/core/src/Op/GatherNd.cpp deleted file mode 100644 index c04db5350..000000000 --- a/compiler/tflchef/core/src/Op/GatherNd.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "GatherNd.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> GatherNdChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::GatherNdOptionsBuilder gather_nd_options_builder{fbb}; - return gather_nd_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> GatherNdChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new GatherNdChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/GatherNd.h b/compiler/tflchef/core/src/Op/GatherNd.h deleted file mode 100644 index 8865e7756..000000000 --- a/compiler/tflchef/core/src/Op/GatherNd.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_GATHER_ND_H__ -#define __OP_GATHER_ND_H__ - -#include "OpChef.h" - -class GatherNdChef final : public OpChef -{ -public: - explicit GatherNdChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_GATHER_ND; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_GatherNdOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct GatherNdChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_GATHER_ND_H__ diff --git a/compiler/tflchef/core/src/Op/Greater.cpp b/compiler/tflchef/core/src/Op/Greater.cpp deleted file mode 100644 index 81765aee5..000000000 --- a/compiler/tflchef/core/src/Op/Greater.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Greater.h" - -flatbuffers::Offset<void> GreaterChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::GreaterOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> GreaterChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new GreaterChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Greater.h b/compiler/tflchef/core/src/Op/Greater.h deleted file mode 100644 index c54eaa6cc..000000000 --- a/compiler/tflchef/core/src/Op/Greater.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_GREATER_H__ -#define __OP_GREATER_H__ - -#include "OpChef.h" - -class GreaterChef final : public OpChef -{ -public: - explicit GreaterChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_GREATER; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_GreaterOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct GreaterChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_GREATER_H__ diff --git a/compiler/tflchef/core/src/Op/GreaterEqual.cpp b/compiler/tflchef/core/src/Op/GreaterEqual.cpp deleted file mode 100644 index 80045f6aa..000000000 --- a/compiler/tflchef/core/src/Op/GreaterEqual.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "GreaterEqual.h" - -flatbuffers::Offset<void> GreaterEqualChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::GreaterEqualOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> GreaterEqualChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new GreaterEqualChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/GreaterEqual.h b/compiler/tflchef/core/src/Op/GreaterEqual.h deleted file mode 100644 index 105bac8a7..000000000 --- a/compiler/tflchef/core/src/Op/GreaterEqual.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_GREATEREQUAL_H__ -#define __OP_GREATEREQUAL_H__ - -#include "OpChef.h" - -class GreaterEqualChef final : public OpChef -{ -public: - explicit GreaterEqualChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_GREATER_EQUAL; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_GreaterEqualOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct GreaterEqualChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_GREATEREQUAL_H__ diff --git a/compiler/tflchef/core/src/Op/If.cpp b/compiler/tflchef/core/src/Op/If.cpp deleted file mode 100644 index b0e575e2b..000000000 --- a/compiler/tflchef/core/src/Op/If.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "If.h" - -flatbuffers::Offset<void> IfChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_if_options()); - - tflite::IfOptionsBuilder if_options_builder{fbb}; - if_options_builder.add_then_subgraph_index(operation.if_options().then_subgraph_index()); - if_options_builder.add_else_subgraph_index(operation.if_options().else_subgraph_index()); - - return if_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> IfChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new IfChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/If.h b/compiler/tflchef/core/src/Op/If.h deleted file mode 100644 index 7e18c5609..000000000 --- a/compiler/tflchef/core/src/Op/If.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_IF_H__ -#define __OP_IF_H__ - -#include "OpChef.h" - -class IfChef final : public OpChef -{ -public: - explicit IfChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_IF; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_IfOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct IfChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_IF_H__ diff --git a/compiler/tflchef/core/src/Op/L2Normalize.cpp b/compiler/tflchef/core/src/Op/L2Normalize.cpp deleted file mode 100644 index 62d15e56e..000000000 --- a/compiler/tflchef/core/src/Op/L2Normalize.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "L2Normalize.h" -#include "Convert.h" - -flatbuffers::Offset<void> L2Normalize::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - tflite::L2NormOptionsBuilder l2norm_options_builder{fbb}; - auto tflite_activation = as_tflite_activation(operation.l2norm_options().activation()); - l2norm_options_builder.add_fused_activation_function(tflite_activation); - return l2norm_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> L2NormalizeChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new L2Normalize{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/L2Normalize.h b/compiler/tflchef/core/src/Op/L2Normalize.h deleted file mode 100644 index dd5f21cae..000000000 --- a/compiler/tflchef/core/src/Op/L2Normalize.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_L2NORMALIZE_H__ -#define __OP_L2NORMALIZE_H__ - -#include "OpChef.h" - -class L2Normalize final : public OpChef -{ -public: - explicit L2Normalize(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_L2_NORMALIZATION; - } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_L2NormOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct L2NormalizeChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_L2NORMALIZE_H__ diff --git a/compiler/tflchef/core/src/Op/L2Pool2D.cpp b/compiler/tflchef/core/src/Op/L2Pool2D.cpp deleted file mode 100644 index f22bb9642..000000000 --- a/compiler/tflchef/core/src/Op/L2Pool2D.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "L2Pool2D.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> L2Pool2DChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_l2pool2d_options()); - - auto options = operation.l2pool2d_options(); - - auto tflite_padding = as_tflite_padding(options.padding()); - auto tflite_activation = as_tflite_activation(options.activation()); - - tflite::Pool2DOptionsBuilder options_builder{fbb}; - options_builder.add_padding(tflite_padding); - options_builder.add_stride_h(options.stride_h()); - options_builder.add_stride_w(options.stride_w()); - options_builder.add_filter_width(options.filter_width()); - options_builder.add_filter_height(options.filter_height()); - options_builder.add_fused_activation_function(tflite_activation); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> L2Pool2DChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new L2Pool2DChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/L2Pool2D.h b/compiler/tflchef/core/src/Op/L2Pool2D.h deleted file mode 100644 index 6bd8bdb4d..000000000 --- a/compiler/tflchef/core/src/Op/L2Pool2D.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_L2_POOL_2D_H__ -#define __OP_L2_POOL_2D_H__ - -#include "OpChef.h" - -class L2Pool2DChef final : public OpChef -{ -public: - explicit L2Pool2DChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_L2_POOL_2D; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_Pool2DOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct L2Pool2DChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_L2_POOL_2D_H__ diff --git a/compiler/tflchef/core/src/Op/LeakyRelu.cpp b/compiler/tflchef/core/src/Op/LeakyRelu.cpp deleted file mode 100644 index 247739ac0..000000000 --- a/compiler/tflchef/core/src/Op/LeakyRelu.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LeakyRelu.h" - -flatbuffers::Offset<void> LeakyReluChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - assert(_operation->has_leaky_relu_options()); - - const auto &options = _operation->leaky_relu_options(); - - tflite::LeakyReluOptionsBuilder options_builder{fbb}; - options_builder.add_alpha(options.alpha()); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> LeakyReluChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LeakyReluChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/LeakyRelu.h b/compiler/tflchef/core/src/Op/LeakyRelu.h deleted file mode 100644 index 5449e593b..000000000 --- a/compiler/tflchef/core/src/Op/LeakyRelu.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LEAKY_RELU_H__ -#define __OP_LEAKY_RELU_H__ - -#include "OpChef.h" - -class LeakyReluChef final : public OpChef -{ -public: - explicit LeakyReluChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LEAKY_RELU; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_LeakyReluOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LeakyReluChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LEAKY_RELU_H__ diff --git a/compiler/tflchef/core/src/Op/Less.cpp b/compiler/tflchef/core/src/Op/Less.cpp deleted file mode 100644 index c143d8332..000000000 --- a/compiler/tflchef/core/src/Op/Less.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Less.h" - -flatbuffers::Offset<void> LessChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::LessOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> LessChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LessChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Less.h b/compiler/tflchef/core/src/Op/Less.h deleted file mode 100644 index 280036c3a..000000000 --- a/compiler/tflchef/core/src/Op/Less.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LESS_H__ -#define __OP_LESS_H__ - -#include "OpChef.h" - -class LessChef final : public OpChef -{ -public: - explicit LessChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LESS; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_LessOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LessChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LESS_H__ diff --git a/compiler/tflchef/core/src/Op/LessEqual.cpp b/compiler/tflchef/core/src/Op/LessEqual.cpp deleted file mode 100644 index dc383e785..000000000 --- a/compiler/tflchef/core/src/Op/LessEqual.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LessEqual.h" - -flatbuffers::Offset<void> LessEqualChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::LessEqualOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> LessEqualChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LessEqualChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/LessEqual.h b/compiler/tflchef/core/src/Op/LessEqual.h deleted file mode 100644 index 1315b9c53..000000000 --- a/compiler/tflchef/core/src/Op/LessEqual.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LESSEQUAL_H__ -#define __OP_LESSEQUAL_H__ - -#include "OpChef.h" - -class LessEqualChef final : public OpChef -{ -public: - explicit LessEqualChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LESS_EQUAL; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_LessEqualOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LessEqualChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LESSEQUAL_H__ diff --git a/compiler/tflchef/core/src/Op/LocalResponseNormalization.cpp b/compiler/tflchef/core/src/Op/LocalResponseNormalization.cpp deleted file mode 100644 index f5430d4ca..000000000 --- a/compiler/tflchef/core/src/Op/LocalResponseNormalization.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LocalResponseNormalization.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> -LocalResponseNormalizationChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_local_response_normalization_options()); - - auto &lrn_options = operation.local_response_normalization_options(); - - auto tflite_radius = lrn_options.radius(); - auto tflite_bias = lrn_options.bias(); - auto tflite_alpha = lrn_options.alpha(); - auto tflite_beta = lrn_options.beta(); - - tflite::LocalResponseNormalizationOptionsBuilder lrn_options_builder{fbb}; - - lrn_options_builder.add_radius(tflite_radius); - lrn_options_builder.add_bias(tflite_bias); - lrn_options_builder.add_alpha(tflite_alpha); - lrn_options_builder.add_beta(tflite_beta); - - return lrn_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> -LocalResponseNormalizationChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LocalResponseNormalizationChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/LocalResponseNormalization.h b/compiler/tflchef/core/src/Op/LocalResponseNormalization.h deleted file mode 100644 index 62a2355f2..000000000 --- a/compiler/tflchef/core/src/Op/LocalResponseNormalization.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LOCAL_RESPONSE_NORMALIZATION_H__ -#define __OP_LOCAL_RESPONSE_NORMALIZATION_H__ - -#include "OpChef.h" - -class LocalResponseNormalizationChef final : public OpChef -{ -public: - explicit LocalResponseNormalizationChef(const tflchef::Operation *operation) - : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_LOCAL_RESPONSE_NORMALIZATION; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_LocalResponseNormalizationOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LocalResponseNormalizationChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LOCAL_RESPONSE_NORMALIZATION_H__ diff --git a/compiler/tflchef/core/src/Op/Log.cpp b/compiler/tflchef/core/src/Op/Log.cpp deleted file mode 100644 index c4e65adec..000000000 --- a/compiler/tflchef/core/src/Op/Log.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Log.h" - -flatbuffers::Offset<void> LogChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Log. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> LogChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LogChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Log.h b/compiler/tflchef/core/src/Op/Log.h deleted file mode 100644 index 2cc8a663b..000000000 --- a/compiler/tflchef/core/src/Op/Log.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LOG_H__ -#define __OP_LOG_H__ - -#include "OpChef.h" - -class LogChef final : public OpChef -{ -public: - explicit LogChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LOG; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LogChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LOG_H__ diff --git a/compiler/tflchef/core/src/Op/LogSoftmax.cpp b/compiler/tflchef/core/src/Op/LogSoftmax.cpp deleted file mode 100644 index eb2f13243..000000000 --- a/compiler/tflchef/core/src/Op/LogSoftmax.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogSoftmax.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> LogSoftmaxChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::LogSoftmaxOptionsBuilder soft_options_builder{fbb}; - - return soft_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> LogSoftmaxChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LogSoftmaxChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/LogSoftmax.h b/compiler/tflchef/core/src/Op/LogSoftmax.h deleted file mode 100644 index 3ce08b739..000000000 --- a/compiler/tflchef/core/src/Op/LogSoftmax.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LOG_SOFTMAX_H__ -#define __OP_LOG_SOFTMAX_H__ - -#include "OpChef.h" - -class LogSoftmaxChef final : public OpChef -{ -public: - explicit LogSoftmaxChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LOG_SOFTMAX; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_LogSoftmaxOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LogSoftmaxChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LOG_SOFTMAX_H__ diff --git a/compiler/tflchef/core/src/Op/LogicalAnd.cpp b/compiler/tflchef/core/src/Op/LogicalAnd.cpp deleted file mode 100644 index 64a6113db..000000000 --- a/compiler/tflchef/core/src/Op/LogicalAnd.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogicalAnd.h" - -flatbuffers::Offset<void> LogicalAndChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::LogicalAndOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> LogicalAndChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LogicalAndChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/LogicalAnd.h b/compiler/tflchef/core/src/Op/LogicalAnd.h deleted file mode 100644 index 1f272274f..000000000 --- a/compiler/tflchef/core/src/Op/LogicalAnd.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LOGICALAND_H__ -#define __OP_LOGICALAND_H__ - -#include "OpChef.h" - -class LogicalAndChef final : public OpChef -{ -public: - explicit LogicalAndChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LOGICAL_AND; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_LogicalAndOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LogicalAndChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LOGICALAND_H__ diff --git a/compiler/tflchef/core/src/Op/LogicalNot.cpp b/compiler/tflchef/core/src/Op/LogicalNot.cpp deleted file mode 100644 index 26cdef308..000000000 --- a/compiler/tflchef/core/src/Op/LogicalNot.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogicalNot.h" - -flatbuffers::Offset<void> LogicalNotChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::LogicalNotOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> LogicalNotChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LogicalNotChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/LogicalNot.h b/compiler/tflchef/core/src/Op/LogicalNot.h deleted file mode 100644 index d2ca21b93..000000000 --- a/compiler/tflchef/core/src/Op/LogicalNot.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LOGICALNOT_H__ -#define __OP_LOGICALNOT_H__ - -#include "OpChef.h" - -class LogicalNotChef final : public OpChef -{ -public: - explicit LogicalNotChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LOGICAL_NOT; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_LogicalNotOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LogicalNotChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LOGICALNOT_H__ diff --git a/compiler/tflchef/core/src/Op/LogicalOr.cpp b/compiler/tflchef/core/src/Op/LogicalOr.cpp deleted file mode 100644 index 483373a81..000000000 --- a/compiler/tflchef/core/src/Op/LogicalOr.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogicalOr.h" - -flatbuffers::Offset<void> LogicalOrChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::LogicalOrOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> LogicalOrChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LogicalOrChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/LogicalOr.h b/compiler/tflchef/core/src/Op/LogicalOr.h deleted file mode 100644 index b84c9a6ab..000000000 --- a/compiler/tflchef/core/src/Op/LogicalOr.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LOGICALOR_H__ -#define __OP_LOGICALOR_H__ - -#include "OpChef.h" - -class LogicalOrChef final : public OpChef -{ -public: - explicit LogicalOrChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LOGICAL_OR; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_LogicalOrOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LogicalOrChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LOGICALOR_H__ diff --git a/compiler/tflchef/core/src/Op/Logistic.cpp b/compiler/tflchef/core/src/Op/Logistic.cpp deleted file mode 100644 index 4a5808235..000000000 --- a/compiler/tflchef/core/src/Op/Logistic.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Logistic.h" - -flatbuffers::Offset<void> LogisticChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Logistic. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> LogisticChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new LogisticChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Logistic.h b/compiler/tflchef/core/src/Op/Logistic.h deleted file mode 100644 index c158af34d..000000000 --- a/compiler/tflchef/core/src/Op/Logistic.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_LOGISTIC_H__ -#define __OP_LOGISTIC_H__ - -#include "OpChef.h" - -class LogisticChef final : public OpChef -{ -public: - explicit LogisticChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_LOGISTIC; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct LogisticChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_LOGISTIC_H__ diff --git a/compiler/tflchef/core/src/Op/MatrixDiag.cpp b/compiler/tflchef/core/src/Op/MatrixDiag.cpp deleted file mode 100644 index de505c056..000000000 --- a/compiler/tflchef/core/src/Op/MatrixDiag.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MatrixDiag.h" - -flatbuffers::Offset<void> MatrixDiagChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::MatrixDiagOptionsBuilder options_builder{fbb}; - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> MatrixDiagChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MatrixDiagChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/MatrixDiag.h b/compiler/tflchef/core/src/Op/MatrixDiag.h deleted file mode 100644 index cbadf6b99..000000000 --- a/compiler/tflchef/core/src/Op/MatrixDiag.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MATRIX_DIAG_H__ -#define __OP_MATRIX_DIAG_H__ - -#include "OpChef.h" - -class MatrixDiagChef final : public OpChef -{ -public: - explicit MatrixDiagChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_MATRIX_DIAG; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_MatrixDiagOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MatrixDiagChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MATRIX_DIAG_H__ diff --git a/compiler/tflchef/core/src/Op/MatrixSetDiag.cpp b/compiler/tflchef/core/src/Op/MatrixSetDiag.cpp deleted file mode 100644 index 0a4ee71c9..000000000 --- a/compiler/tflchef/core/src/Op/MatrixSetDiag.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MatrixSetDiag.h" - -flatbuffers::Offset<void> MatrixSetDiagChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::MatrixSetDiagOptionsBuilder options_builder{fbb}; - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> MatrixSetDiagChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MatrixSetDiagChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/MatrixSetDiag.h b/compiler/tflchef/core/src/Op/MatrixSetDiag.h deleted file mode 100644 index 8114d32a8..000000000 --- a/compiler/tflchef/core/src/Op/MatrixSetDiag.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MATRIX_SET_DIAG_H__ -#define __OP_MATRIX_SET_DIAG_H__ - -#include "OpChef.h" - -class MatrixSetDiagChef final : public OpChef -{ -public: - explicit MatrixSetDiagChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_MATRIX_SET_DIAG; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_MatrixSetDiagOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MatrixSetDiagChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MATRIX_SET_DIAG_H__ diff --git a/compiler/tflchef/core/src/Op/Maximum.cpp b/compiler/tflchef/core/src/Op/Maximum.cpp deleted file mode 100644 index 8f415e2e4..000000000 --- a/compiler/tflchef/core/src/Op/Maximum.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Maximum.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> MaximumChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::MaximumMinimumOptionsBuilder maximum_options_builder{fbb}; - return maximum_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> MaximumChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MaximumChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Maximum.h b/compiler/tflchef/core/src/Op/Maximum.h deleted file mode 100644 index 53e95240c..000000000 --- a/compiler/tflchef/core/src/Op/Maximum.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MAXIMUM_H__ -#define __OP_MAXIMUM_H__ - -#include "OpChef.h" - -class MaximumChef final : public OpChef -{ -public: - explicit MaximumChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_MAXIMUM; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_MaximumMinimumOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MaximumChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MAXIMUM_H__ diff --git a/compiler/tflchef/core/src/Op/Mean.cpp b/compiler/tflchef/core/src/Op/Mean.cpp deleted file mode 100644 index def8f7b3b..000000000 --- a/compiler/tflchef/core/src/Op/Mean.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Mean.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> MeanChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_mean_options()); - - auto keep_dims = operation.mean_options().keep_dims(); - - tflite::ReducerOptionsBuilder mean_options_builder{fbb}; - mean_options_builder.add_keep_dims(keep_dims); - - return mean_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> MeanChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MeanChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Mean.h b/compiler/tflchef/core/src/Op/Mean.h deleted file mode 100644 index 9032aef3f..000000000 --- a/compiler/tflchef/core/src/Op/Mean.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MEAN_H__ -#define __OP_MEAN_H__ - -#include "OpChef.h" - -class MeanChef final : public OpChef -{ -public: - explicit MeanChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_MEAN; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ReducerOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MeanChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MEAN_H__ diff --git a/compiler/tflchef/core/src/Op/Minimum.cpp b/compiler/tflchef/core/src/Op/Minimum.cpp deleted file mode 100644 index cc0c91901..000000000 --- a/compiler/tflchef/core/src/Op/Minimum.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Minimum.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> MinimumChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::MaximumMinimumOptionsBuilder minimum_options_builder{fbb}; - return minimum_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> MinimumChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MinimumChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Minimum.h b/compiler/tflchef/core/src/Op/Minimum.h deleted file mode 100644 index 3990e1eca..000000000 --- a/compiler/tflchef/core/src/Op/Minimum.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MINIMUM_H__ -#define __OP_MINIMUM_H__ - -#include "OpChef.h" - -class MinimumChef final : public OpChef -{ -public: - explicit MinimumChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_MINIMUM; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_MaximumMinimumOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MinimumChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MINIMUM_H__ diff --git a/compiler/tflchef/core/src/Op/MirrorPad.cpp b/compiler/tflchef/core/src/Op/MirrorPad.cpp deleted file mode 100644 index 2d68b6986..000000000 --- a/compiler/tflchef/core/src/Op/MirrorPad.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MirrorPad.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> MirrorPadChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_mirrorpad_options()); - - auto options = operation.mirrorpad_options(); - - auto tflite_mode = as_tflite_mirrorpadmode(options.mode()); - - tflite::MirrorPadOptionsBuilder options_builder{fbb}; - options_builder.add_mode(tflite_mode); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> MirrorPadChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MirrorPadChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/MirrorPad.h b/compiler/tflchef/core/src/Op/MirrorPad.h deleted file mode 100644 index 49461df35..000000000 --- a/compiler/tflchef/core/src/Op/MirrorPad.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MIRRORPAD_H__ -#define __OP_MIRRORPAD_H__ - -#include "OpChef.h" - -class MirrorPadChef final : public OpChef -{ -public: - explicit MirrorPadChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_MIRROR_PAD; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_MirrorPadOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MirrorPadChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MIRRORPAD_H__ diff --git a/compiler/tflchef/core/src/Op/Mul.cpp b/compiler/tflchef/core/src/Op/Mul.cpp deleted file mode 100644 index 10ec918c2..000000000 --- a/compiler/tflchef/core/src/Op/Mul.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Mul.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> MulChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_mul_options()); - - auto tflite_activation = as_tflite_activation(operation.mul_options().activation()); - - tflite::MulOptionsBuilder mul_options_builder{fbb}; - mul_options_builder.add_fused_activation_function(tflite_activation); - - return mul_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> MulChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new MulChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Mul.h b/compiler/tflchef/core/src/Op/Mul.h deleted file mode 100644 index 7f1d07ac9..000000000 --- a/compiler/tflchef/core/src/Op/Mul.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_MUL_H__ -#define __OP_MUL_H__ - -#include "OpChef.h" - -class MulChef final : public OpChef -{ -public: - explicit MulChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_MUL; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_MulOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct MulChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_MUL_H__ diff --git a/compiler/tflchef/core/src/Op/Neg.cpp b/compiler/tflchef/core/src/Op/Neg.cpp deleted file mode 100644 index 0e9fb9321..000000000 --- a/compiler/tflchef/core/src/Op/Neg.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Neg.h" -#include "Convert.h" - -flatbuffers::Offset<void> NegChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::NegOptionsBuilder neg_options_builder{fbb}; - - return neg_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> NegChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new NegChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Neg.h b/compiler/tflchef/core/src/Op/Neg.h deleted file mode 100644 index f7a2692c9..000000000 --- a/compiler/tflchef/core/src/Op/Neg.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_NEG_H__ -#define __OP_NEG_H__ - -#include "OpChef.h" - -class NegChef final : public OpChef -{ -public: - explicit NegChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_NEG; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NegOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct NegChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_NEG_H__ diff --git a/compiler/tflchef/core/src/Op/NonMaxSuppressionV4.cpp b/compiler/tflchef/core/src/Op/NonMaxSuppressionV4.cpp deleted file mode 100644 index eadd62cc6..000000000 --- a/compiler/tflchef/core/src/Op/NonMaxSuppressionV4.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "NonMaxSuppressionV4.h" - -flatbuffers::Offset<void> NonMaxSuppressionV4Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::NonMaxSuppressionV4OptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> -NonMaxSuppressionV4ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new NonMaxSuppressionV4Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/NonMaxSuppressionV4.h b/compiler/tflchef/core/src/Op/NonMaxSuppressionV4.h deleted file mode 100644 index a8e783d53..000000000 --- a/compiler/tflchef/core/src/Op/NonMaxSuppressionV4.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_NON_MAX_SUPPRESSION_V4_H__ -#define __OP_NON_MAX_SUPPRESSION_V4_H__ - -#include "OpChef.h" - -class NonMaxSuppressionV4Chef final : public OpChef -{ -public: - explicit NonMaxSuppressionV4Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_NON_MAX_SUPPRESSION_V4; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_NonMaxSuppressionV4Options; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct NonMaxSuppressionV4ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_NON_MAX_SUPPRESSION_V4_H__ diff --git a/compiler/tflchef/core/src/Op/NonMaxSuppressionV5.cpp b/compiler/tflchef/core/src/Op/NonMaxSuppressionV5.cpp deleted file mode 100644 index 500aa467f..000000000 --- a/compiler/tflchef/core/src/Op/NonMaxSuppressionV5.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "NonMaxSuppressionV5.h" - -flatbuffers::Offset<void> NonMaxSuppressionV5Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::NonMaxSuppressionV5OptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> -NonMaxSuppressionV5ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new NonMaxSuppressionV5Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/NonMaxSuppressionV5.h b/compiler/tflchef/core/src/Op/NonMaxSuppressionV5.h deleted file mode 100644 index a3c8b6009..000000000 --- a/compiler/tflchef/core/src/Op/NonMaxSuppressionV5.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_NON_MAX_SUPPRESSION_V5_H__ -#define __OP_NON_MAX_SUPPRESSION_V5_H__ - -#include "OpChef.h" - -class NonMaxSuppressionV5Chef final : public OpChef -{ -public: - explicit NonMaxSuppressionV5Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_NON_MAX_SUPPRESSION_V5; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_NonMaxSuppressionV5Options; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct NonMaxSuppressionV5ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_NON_MAX_SUPPRESSION_V5_H__ diff --git a/compiler/tflchef/core/src/Op/NotEqual.cpp b/compiler/tflchef/core/src/Op/NotEqual.cpp deleted file mode 100644 index a408266f9..000000000 --- a/compiler/tflchef/core/src/Op/NotEqual.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "NotEqual.h" - -flatbuffers::Offset<void> NotEqualChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::NotEqualOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> NotEqualChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new NotEqualChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/NotEqual.h b/compiler/tflchef/core/src/Op/NotEqual.h deleted file mode 100644 index 3fd254773..000000000 --- a/compiler/tflchef/core/src/Op/NotEqual.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_NOT_EQUAL_H__ -#define __OP_NOT_EQUAL_H__ - -#include "OpChef.h" - -class NotEqualChef final : public OpChef -{ -public: - explicit NotEqualChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_NOT_EQUAL; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_NotEqualOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct NotEqualChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_NOT_EQUAL_H__ diff --git a/compiler/tflchef/core/src/Op/OneHot.cpp b/compiler/tflchef/core/src/Op/OneHot.cpp deleted file mode 100644 index 421e50c9f..000000000 --- a/compiler/tflchef/core/src/Op/OneHot.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "OneHot.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> OneHotChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_onehot_options()); - - auto options = operation.onehot_options(); - - tflite::OneHotOptionsBuilder options_builder{fbb}; - - options_builder.add_axis(options.axis()); - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> OneHotChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new OneHotChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/OneHot.h b/compiler/tflchef/core/src/Op/OneHot.h deleted file mode 100644 index b29cb7978..000000000 --- a/compiler/tflchef/core/src/Op/OneHot.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ONEHOT_H__ -#define __OP_ONEHOT_H__ - -#include "OpChef.h" - -class OneHotChef final : public OpChef -{ -public: - explicit OneHotChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ONE_HOT; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_OneHotOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct OneHotChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ONEHOT_H__ diff --git a/compiler/tflchef/core/src/Op/PRelu.cpp b/compiler/tflchef/core/src/Op/PRelu.cpp deleted file mode 100644 index 30e8b8ef4..000000000 --- a/compiler/tflchef/core/src/Op/PRelu.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "PRelu.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> PReluChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No option for PRelu - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> PReluChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new PReluChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/PRelu.h b/compiler/tflchef/core/src/Op/PRelu.h deleted file mode 100644 index 4a5a935ed..000000000 --- a/compiler/tflchef/core/src/Op/PRelu.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_PRELU_H__ -#define __OP_PRELU_H__ - -#include "OpChef.h" - -class PReluChef final : public OpChef -{ -public: - explicit PReluChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_PRELU; } - - // no builtin options for PRelu - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct PReluChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_PRELU_H__ diff --git a/compiler/tflchef/core/src/Op/Pack.cpp b/compiler/tflchef/core/src/Op/Pack.cpp deleted file mode 100644 index 2532ac744..000000000 --- a/compiler/tflchef/core/src/Op/Pack.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Pack.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> PackChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_pack_options()); - - tflite::PackOptionsBuilder pack_options_builder{fbb}; - pack_options_builder.add_values_count(operation.pack_options().values_count()); - pack_options_builder.add_axis(operation.pack_options().axis()); - - return pack_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> PackChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new PackChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Pack.h b/compiler/tflchef/core/src/Op/Pack.h deleted file mode 100644 index 54bdc9338..000000000 --- a/compiler/tflchef/core/src/Op/Pack.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_PACK_H__ -#define __OP_PACK_H__ - -#include "OpChef.h" - -class PackChef final : public OpChef -{ -public: - explicit PackChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_PACK; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_PackOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct PackChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_PACK_H__ diff --git a/compiler/tflchef/core/src/Op/Pad.cpp b/compiler/tflchef/core/src/Op/Pad.cpp deleted file mode 100644 index d0c471981..000000000 --- a/compiler/tflchef/core/src/Op/Pad.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Pad.h" - -flatbuffers::Offset<void> PadChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::PadOptionsBuilder pad_options_builder{fbb}; - return pad_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> PadChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new PadChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Pad.h b/compiler/tflchef/core/src/Op/Pad.h deleted file mode 100644 index 9da9c9b8a..000000000 --- a/compiler/tflchef/core/src/Op/Pad.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_PAD_H__ -#define __OP_PAD_H__ - -#include "OpChef.h" - -class PadChef final : public OpChef -{ -public: - explicit PadChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_PAD; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_PadOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct PadChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_PAD_H__ diff --git a/compiler/tflchef/core/src/Op/PadV2.cpp b/compiler/tflchef/core/src/Op/PadV2.cpp deleted file mode 100644 index bfa2289e5..000000000 --- a/compiler/tflchef/core/src/Op/PadV2.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "PadV2.h" - -flatbuffers::Offset<void> PadV2Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::PadV2OptionsBuilder padv2_options_builder{fbb}; - return padv2_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> PadV2ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new PadV2Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/PadV2.h b/compiler/tflchef/core/src/Op/PadV2.h deleted file mode 100644 index d15532390..000000000 --- a/compiler/tflchef/core/src/Op/PadV2.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_PADV2_H__ -#define __OP_PADV2_H__ - -#include "OpChef.h" - -class PadV2Chef final : public OpChef -{ -public: - explicit PadV2Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_PADV2; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_PadV2Options; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct PadV2ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_PADV2_H__ diff --git a/compiler/tflchef/core/src/Op/Pow.cpp b/compiler/tflchef/core/src/Op/Pow.cpp deleted file mode 100644 index 25e180237..000000000 --- a/compiler/tflchef/core/src/Op/Pow.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Pow.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> PowChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::PowOptionsBuilder options_builder{fbb}; - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> PowChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new PowChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Pow.h b/compiler/tflchef/core/src/Op/Pow.h deleted file mode 100644 index f2d809e92..000000000 --- a/compiler/tflchef/core/src/Op/Pow.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_POW_H__ -#define __OP_POW_H__ - -#include "OpChef.h" - -class PowChef final : public OpChef -{ -public: - explicit PowChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_POW; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_PowOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct PowChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_POW_H__ diff --git a/compiler/tflchef/core/src/Op/Range.cpp b/compiler/tflchef/core/src/Op/Range.cpp deleted file mode 100644 index 189c46526..000000000 --- a/compiler/tflchef/core/src/Op/Range.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Range.h" - -#include <cassert> -#include <vector> - -flatbuffers::Offset<void> RangeChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::RangeOptionsBuilder options_builder{fbb}; - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> RangeChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new RangeChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Range.h b/compiler/tflchef/core/src/Op/Range.h deleted file mode 100644 index f294d15a7..000000000 --- a/compiler/tflchef/core/src/Op/Range.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_RANGE_H__ -#define __OP_RANGE_H__ - -#include "OpChef.h" - -class RangeChef final : public OpChef -{ -public: - explicit RangeChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_RANGE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_RangeOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct RangeChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_RANGE_H__ diff --git a/compiler/tflchef/core/src/Op/Rank.cpp b/compiler/tflchef/core/src/Op/Rank.cpp deleted file mode 100644 index 4eb2aa776..000000000 --- a/compiler/tflchef/core/src/Op/Rank.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Rank.h" - -flatbuffers::Offset<void> RankChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::RankOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> RankChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new RankChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Rank.h b/compiler/tflchef/core/src/Op/Rank.h deleted file mode 100644 index 0bce38095..000000000 --- a/compiler/tflchef/core/src/Op/Rank.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_RANK_H__ -#define __OP_RANK_H__ - -#include "OpChef.h" - -class RankChef final : public OpChef -{ -public: - explicit RankChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_RANK; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_RankOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct RankChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_RANK_H__ diff --git a/compiler/tflchef/core/src/Op/ReLUN1To1.cpp b/compiler/tflchef/core/src/Op/ReLUN1To1.cpp deleted file mode 100644 index d57e82341..000000000 --- a/compiler/tflchef/core/src/Op/ReLUN1To1.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReLUN1To1.h" - -flatbuffers::Offset<void> ReLUN1To1Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> ReLUN1To1ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ReLUN1To1Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ReLUN1To1.h b/compiler/tflchef/core/src/Op/ReLUN1To1.h deleted file mode 100644 index e034c7999..000000000 --- a/compiler/tflchef/core/src/Op/ReLUN1To1.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_RELU_N1_TO_1_H__ -#define __OP_RELU_N1_TO_1_H__ - -#include "OpChef.h" - -class ReLUN1To1Chef final : public OpChef -{ -public: - explicit ReLUN1To1Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_RELU_N1_TO_1; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ReLUN1To1ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_RELU_N1_TO_1_H__ diff --git a/compiler/tflchef/core/src/Op/ReduceAny.cpp b/compiler/tflchef/core/src/Op/ReduceAny.cpp deleted file mode 100644 index c94c8a3a4..000000000 --- a/compiler/tflchef/core/src/Op/ReduceAny.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceAny.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ReduceAnyChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_reduce_any_options()); - - auto keep_dims = operation.reduce_any_options().keep_dims(); - - tflite::ReducerOptionsBuilder reducer_options_builder{fbb}; - reducer_options_builder.add_keep_dims(keep_dims); - - return reducer_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ReduceAnyChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ReduceAnyChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ReduceAny.h b/compiler/tflchef/core/src/Op/ReduceAny.h deleted file mode 100644 index cf6531732..000000000 --- a/compiler/tflchef/core/src/Op/ReduceAny.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_REDUCE_ANY_H__ -#define __OP_REDUCE_ANY_H__ - -#include "OpChef.h" - -class ReduceAnyChef final : public OpChef -{ -public: - explicit ReduceAnyChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_REDUCE_ANY; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ReducerOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ReduceAnyChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_REDUCE_ANY_H__ diff --git a/compiler/tflchef/core/src/Op/ReduceMax.cpp b/compiler/tflchef/core/src/Op/ReduceMax.cpp deleted file mode 100644 index 31543cdc0..000000000 --- a/compiler/tflchef/core/src/Op/ReduceMax.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceMax.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ReduceMaxChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_reduce_max_options()); - - auto keep_dims = operation.reduce_max_options().keep_dims(); - - tflite::ReducerOptionsBuilder reduce_max_options_builder{fbb}; - reduce_max_options_builder.add_keep_dims(keep_dims); - - return reduce_max_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ReduceMaxChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ReduceMaxChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ReduceMax.h b/compiler/tflchef/core/src/Op/ReduceMax.h deleted file mode 100644 index 854c5b87d..000000000 --- a/compiler/tflchef/core/src/Op/ReduceMax.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_REDUCEMAX_H__ -#define __OP_REDUCEMAX_H__ - -#include "OpChef.h" - -class ReduceMaxChef final : public OpChef -{ -public: - explicit ReduceMaxChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_REDUCE_MAX; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ReducerOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ReduceMaxChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_REDUCEMAX_H__ diff --git a/compiler/tflchef/core/src/Op/ReduceMin.cpp b/compiler/tflchef/core/src/Op/ReduceMin.cpp deleted file mode 100644 index e194a1837..000000000 --- a/compiler/tflchef/core/src/Op/ReduceMin.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceMin.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ReduceMinChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_reduce_min_options()); - - auto keep_dims = operation.reduce_min_options().keep_dims(); - - tflite::ReducerOptionsBuilder reduce_min_options_builder{fbb}; - reduce_min_options_builder.add_keep_dims(keep_dims); - - return reduce_min_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ReduceMinChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ReduceMinChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ReduceMin.h b/compiler/tflchef/core/src/Op/ReduceMin.h deleted file mode 100644 index f29d273b9..000000000 --- a/compiler/tflchef/core/src/Op/ReduceMin.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_REDUCEMIN_H__ -#define __OP_REDUCEMIN_H__ - -#include "OpChef.h" - -class ReduceMinChef final : public OpChef -{ -public: - explicit ReduceMinChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_REDUCE_MIN; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ReducerOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ReduceMinChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_REDUCEMIN_H__ diff --git a/compiler/tflchef/core/src/Op/ReduceProd.cpp b/compiler/tflchef/core/src/Op/ReduceProd.cpp deleted file mode 100644 index c89aca27e..000000000 --- a/compiler/tflchef/core/src/Op/ReduceProd.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceProd.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ReduceProdChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_reduce_prod_options()); - - auto keep_dims = operation.reduce_prod_options().keep_dims(); - - tflite::ReducerOptionsBuilder reducer_options_builder{fbb}; - reducer_options_builder.add_keep_dims(keep_dims); - - return reducer_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ReduceProdChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ReduceProdChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ReduceProd.h b/compiler/tflchef/core/src/Op/ReduceProd.h deleted file mode 100644 index d5a11fdbc..000000000 --- a/compiler/tflchef/core/src/Op/ReduceProd.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_REDUCE_PROD_H__ -#define __OP_REDUCE_PROD_H__ - -#include "OpChef.h" - -class ReduceProdChef final : public OpChef -{ -public: - explicit ReduceProdChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_REDUCE_PROD; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ReducerOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ReduceProdChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_REDUCE_PROD_H__ diff --git a/compiler/tflchef/core/src/Op/Reshape.cpp b/compiler/tflchef/core/src/Op/Reshape.cpp index 01e521913..99555e898 100644 --- a/compiler/tflchef/core/src/Op/Reshape.cpp +++ b/compiler/tflchef/core/src/Op/Reshape.cpp @@ -41,8 +41,7 @@ flatbuffers::Offset<void> ReshapeChef::value(flatbuffers::FlatBufferBuilder &fbb { auto &operation = (*_operation); - if (!operation.has_reshape_options()) - return 0; + assert(operation.has_reshape_options()); auto options = operation.reshape_options(); auto shapes = vector_new_shape(options); diff --git a/compiler/tflchef/core/src/Op/ResizeBilinear.cpp b/compiler/tflchef/core/src/Op/ResizeBilinear.cpp deleted file mode 100644 index 3d9299ce0..000000000 --- a/compiler/tflchef/core/src/Op/ResizeBilinear.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ResizeBilinear.h" -#include "Convert.h" - -#include <cassert> -#include <vector> - -flatbuffers::Offset<void> ResizeBilinearChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_resize_bilinear_options()); - - auto options = operation.resize_bilinear_options(); - - tflite::ResizeBilinearOptionsBuilder options_builder{fbb}; - - options_builder.add_align_corners(options.align_corners()); - options_builder.add_half_pixel_centers(options.half_pixel_centers()); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ResizeBilinearChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ResizeBilinearChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ResizeBilinear.h b/compiler/tflchef/core/src/Op/ResizeBilinear.h deleted file mode 100644 index 9bd618538..000000000 --- a/compiler/tflchef/core/src/Op/ResizeBilinear.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_RESIZE_BILINEAR_H__ -#define __OP_RESIZE_BILINEAR_H__ - -#include "OpChef.h" - -class ResizeBilinearChef final : public OpChef -{ -public: - explicit ResizeBilinearChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_RESIZE_BILINEAR; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_ResizeBilinearOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ResizeBilinearChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_RESIZE_BILINEAR_H__ diff --git a/compiler/tflchef/core/src/Op/ResizeNearestNeighbor.cpp b/compiler/tflchef/core/src/Op/ResizeNearestNeighbor.cpp deleted file mode 100644 index 1f930404f..000000000 --- a/compiler/tflchef/core/src/Op/ResizeNearestNeighbor.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ResizeNearestNeighbor.h" -#include "Convert.h" - -#include <cassert> -#include <vector> - -flatbuffers::Offset<void> -ResizeNearestNeighborChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_resize_nearest_neighbor_options()); - - auto options = operation.resize_nearest_neighbor_options(); - - tflite::ResizeNearestNeighborOptionsBuilder options_builder{fbb}; - - options_builder.add_align_corners(options.align_corners()); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> -ResizeNearestNeighborChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ResizeNearestNeighborChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ResizeNearestNeighbor.h b/compiler/tflchef/core/src/Op/ResizeNearestNeighbor.h deleted file mode 100644 index e6ee832a8..000000000 --- a/compiler/tflchef/core/src/Op/ResizeNearestNeighbor.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_RESIZE_NEAREST_NEIGHBOR_H__ -#define __OP_RESIZE_NEAREST_NEIGHBOR_H__ - -#include "OpChef.h" - -class ResizeNearestNeighborChef final : public OpChef -{ -public: - explicit ResizeNearestNeighborChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_RESIZE_NEAREST_NEIGHBOR; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_ResizeNearestNeighborOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ResizeNearestNeighborChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_RESIZE_NEAREST_NEIGHBOR_H__ diff --git a/compiler/tflchef/core/src/Op/ReverseSequence.cpp b/compiler/tflchef/core/src/Op/ReverseSequence.cpp deleted file mode 100644 index 93541172b..000000000 --- a/compiler/tflchef/core/src/Op/ReverseSequence.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReverseSequence.h" - -flatbuffers::Offset<void> ReverseSequenceChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_reverse_sequence_options()); - - auto options = operation.reverse_sequence_options(); - - auto tflite_seq_dim = options.seq_dim(); - auto tflite_batch_dim = options.batch_dim(); - - tflite::ReverseSequenceOptionsBuilder options_builder{fbb}; - - options_builder.add_seq_dim(tflite_seq_dim); - options_builder.add_batch_dim(tflite_batch_dim); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> -ReverseSequenceChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ReverseSequenceChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ReverseSequence.h b/compiler/tflchef/core/src/Op/ReverseSequence.h deleted file mode 100644 index 329505cf0..000000000 --- a/compiler/tflchef/core/src/Op/ReverseSequence.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_REVERSE_SEQUENCE_H__ -#define __OP_REVERSE_SEQUENCE_H__ - -#include "OpChef.h" - -class ReverseSequenceChef final : public OpChef -{ -public: - explicit ReverseSequenceChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_REVERSE_SEQUENCE; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_ReverseSequenceOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ReverseSequenceChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_REVERSE_SEQUENCE_H__ diff --git a/compiler/tflchef/core/src/Op/ReverseV2.cpp b/compiler/tflchef/core/src/Op/ReverseV2.cpp deleted file mode 100644 index 58ace1dd1..000000000 --- a/compiler/tflchef/core/src/Op/ReverseV2.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReverseV2.h" - -flatbuffers::Offset<void> ReverseV2Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::ReverseV2OptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ReverseV2ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ReverseV2Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ReverseV2.h b/compiler/tflchef/core/src/Op/ReverseV2.h deleted file mode 100644 index a48a2d96a..000000000 --- a/compiler/tflchef/core/src/Op/ReverseV2.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_REVERSEV2_H__ -#define __OP_REVERSEV2_H__ - -#include "OpChef.h" - -class ReverseV2Chef final : public OpChef -{ -public: - explicit ReverseV2Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_REVERSE_V2; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_ReverseV2Options; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ReverseV2ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_REVERSEV2_H__ diff --git a/compiler/tflchef/core/src/Op/Round.cpp b/compiler/tflchef/core/src/Op/Round.cpp deleted file mode 100644 index e16c86518..000000000 --- a/compiler/tflchef/core/src/Op/Round.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Round.h" - -flatbuffers::Offset<void> RoundChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Round. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> RoundChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new RoundChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Round.h b/compiler/tflchef/core/src/Op/Round.h deleted file mode 100644 index 7f0fbe370..000000000 --- a/compiler/tflchef/core/src/Op/Round.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ROUND_H__ -#define __OP_ROUND_H__ - -#include "OpChef.h" - -class RoundChef final : public OpChef -{ -public: - explicit RoundChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ROUND; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct RoundChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ROUND_H__ diff --git a/compiler/tflchef/core/src/Op/Rsqrt.cpp b/compiler/tflchef/core/src/Op/Rsqrt.cpp deleted file mode 100644 index fa837f6fa..000000000 --- a/compiler/tflchef/core/src/Op/Rsqrt.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Rsqrt.h" - -flatbuffers::Offset<void> RsqrtChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Rsqrt. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> RsqrtChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new RsqrtChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Rsqrt.h b/compiler/tflchef/core/src/Op/Rsqrt.h deleted file mode 100644 index 657f51ccb..000000000 --- a/compiler/tflchef/core/src/Op/Rsqrt.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_RSQRT_H__ -#define __OP_RSQRT_H__ - -#include "OpChef.h" - -class RsqrtChef final : public OpChef -{ -public: - explicit RsqrtChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_RSQRT; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct RsqrtChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_RSQRT_H__ diff --git a/compiler/tflchef/core/src/Op/ScatterNd.cpp b/compiler/tflchef/core/src/Op/ScatterNd.cpp deleted file mode 100644 index 7114dda6e..000000000 --- a/compiler/tflchef/core/src/Op/ScatterNd.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ScatterNd.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ScatterNdChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::ScatterNdOptionsBuilder scatter_nd_options_builder{fbb}; - - return scatter_nd_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ScatterNdChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ScatterNdChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ScatterNd.h b/compiler/tflchef/core/src/Op/ScatterNd.h deleted file mode 100644 index 2c89cf6a0..000000000 --- a/compiler/tflchef/core/src/Op/ScatterNd.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SCATTER_ND_H__ -#define __OP_SCATTER_ND_H__ - -#include "OpChef.h" - -class ScatterNdChef final : public OpChef -{ -public: - explicit ScatterNdChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SCATTER_ND; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_ScatterNdOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ScatterNdChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SCATTER_ND_H__ diff --git a/compiler/tflchef/core/src/Op/SegmentSum.cpp b/compiler/tflchef/core/src/Op/SegmentSum.cpp deleted file mode 100644 index 934bcb0ec..000000000 --- a/compiler/tflchef/core/src/Op/SegmentSum.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SegmentSum.h" - -flatbuffers::Offset<void> SegmentSumChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::SegmentSumOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SegmentSumChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SegmentSumChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/SegmentSum.h b/compiler/tflchef/core/src/Op/SegmentSum.h deleted file mode 100644 index c0ebfba52..000000000 --- a/compiler/tflchef/core/src/Op/SegmentSum.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SEGMENT_SUM_H__ -#define __OP_SEGMENT_SUM_H__ - -#include "OpChef.h" - -class SegmentSumChef final : public OpChef -{ -public: - explicit SegmentSumChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SEGMENT_SUM; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_SegmentSumOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SegmentSumChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SEGMENT_SUM_H__ diff --git a/compiler/tflchef/core/src/Op/Select.cpp b/compiler/tflchef/core/src/Op/Select.cpp deleted file mode 100644 index 31be736c9..000000000 --- a/compiler/tflchef/core/src/Op/Select.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Select.h" - -flatbuffers::Offset<void> SelectChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::SelectOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SelectChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SelectChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Select.h b/compiler/tflchef/core/src/Op/Select.h deleted file mode 100644 index 91ace16e1..000000000 --- a/compiler/tflchef/core/src/Op/Select.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SELECT_H__ -#define __OP_SELECT_H__ - -#include "OpChef.h" - -class SelectChef final : public OpChef -{ -public: - explicit SelectChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SELECT; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_SelectOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SelectChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SELECT_H__ diff --git a/compiler/tflchef/core/src/Op/SelectV2.cpp b/compiler/tflchef/core/src/Op/SelectV2.cpp deleted file mode 100644 index f6c0bfc49..000000000 --- a/compiler/tflchef/core/src/Op/SelectV2.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SelectV2.h" - -flatbuffers::Offset<void> SelectV2Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::SelectV2OptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SelectV2ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SelectV2Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/SelectV2.h b/compiler/tflchef/core/src/Op/SelectV2.h deleted file mode 100644 index 36d74c344..000000000 --- a/compiler/tflchef/core/src/Op/SelectV2.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SELECT_V2_H__ -#define __OP_SELECT_V2_H__ - -#include "OpChef.h" - -class SelectV2Chef final : public OpChef -{ -public: - explicit SelectV2Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SELECT_V2; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_SelectV2Options; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SelectV2ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SELECT_V2_H__ diff --git a/compiler/tflchef/core/src/Op/Shape.cpp b/compiler/tflchef/core/src/Op/Shape.cpp deleted file mode 100644 index 74b1894da..000000000 --- a/compiler/tflchef/core/src/Op/Shape.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Shape.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> ShapeChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_shape_options()); - - auto tflite_out_type = as_tflite_tensortype(operation.shape_options().out_type()); - - tflite::ShapeOptionsBuilder shape_options_builder{fbb}; - shape_options_builder.add_out_type(tflite_out_type); - - return shape_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ShapeChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ShapeChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Shape.h b/compiler/tflchef/core/src/Op/Shape.h deleted file mode 100644 index ddaeb1d95..000000000 --- a/compiler/tflchef/core/src/Op/Shape.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SHAPE_H__ -#define __OP_SHAPE_H__ - -#include "OpChef.h" - -class ShapeChef final : public OpChef -{ -public: - explicit ShapeChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SHAPE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ShapeOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ShapeChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SHAPE_H__ diff --git a/compiler/tflchef/core/src/Op/Sin.cpp b/compiler/tflchef/core/src/Op/Sin.cpp deleted file mode 100644 index 1752ce7a1..000000000 --- a/compiler/tflchef/core/src/Op/Sin.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Sin.h" - -flatbuffers::Offset<void> SinChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Sin. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> SinChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SinChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Sin.h b/compiler/tflchef/core/src/Op/Sin.h deleted file mode 100644 index 121b73b68..000000000 --- a/compiler/tflchef/core/src/Op/Sin.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SIN_H__ -#define __OP_SIN_H__ - -#include "OpChef.h" - -class SinChef final : public OpChef -{ -public: - explicit SinChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SIN; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SinChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SIN_H__ diff --git a/compiler/tflchef/core/src/Op/Slice.cpp b/compiler/tflchef/core/src/Op/Slice.cpp deleted file mode 100644 index 27ae80a8a..000000000 --- a/compiler/tflchef/core/src/Op/Slice.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Slice.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> SliceChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::SliceOptionsBuilder slice_options_builder{fbb}; - return slice_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SliceChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SliceChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Slice.h b/compiler/tflchef/core/src/Op/Slice.h deleted file mode 100644 index 06fd6347b..000000000 --- a/compiler/tflchef/core/src/Op/Slice.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SLICE_H__ -#define __OP_SLICE_H__ - -#include "OpChef.h" - -class SliceChef final : public OpChef -{ -public: - explicit SliceChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SLICE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_SliceOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SliceChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SLICE_H__ diff --git a/compiler/tflchef/core/src/Op/Softmax.cpp b/compiler/tflchef/core/src/Op/Softmax.cpp deleted file mode 100644 index a554e0d81..000000000 --- a/compiler/tflchef/core/src/Op/Softmax.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Softmax.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> SoftmaxChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_softmax_options()); - - auto tflite_beta = operation.softmax_options().beta(); - - tflite::SoftmaxOptionsBuilder soft_options_builder{fbb}; - soft_options_builder.add_beta(tflite_beta); - - return soft_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SoftmaxChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SoftmaxChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Softmax.h b/compiler/tflchef/core/src/Op/Softmax.h deleted file mode 100644 index 8b3f0ebf6..000000000 --- a/compiler/tflchef/core/src/Op/Softmax.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SOFTMAX_H__ -#define __OP_SOFTMAX_H__ - -#include "OpChef.h" - -class SoftmaxChef final : public OpChef -{ -public: - explicit SoftmaxChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SOFTMAX; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_SoftmaxOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SoftmaxChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SOFTMAX_H__ diff --git a/compiler/tflchef/core/src/Op/SpaceToBatchND.cpp b/compiler/tflchef/core/src/Op/SpaceToBatchND.cpp deleted file mode 100644 index 74e052826..000000000 --- a/compiler/tflchef/core/src/Op/SpaceToBatchND.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SpaceToBatchND.h" - -#include <cassert> - -flatbuffers::Offset<void> SpaceToBatchNDChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::SpaceToBatchNDOptionsBuilder space_to_batch_nd_options_builder{fbb}; - - return space_to_batch_nd_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SpaceToBatchNDChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SpaceToBatchNDChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/SpaceToBatchND.h b/compiler/tflchef/core/src/Op/SpaceToBatchND.h deleted file mode 100644 index e263bdc61..000000000 --- a/compiler/tflchef/core/src/Op/SpaceToBatchND.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SPACETOBATCHND_H__ -#define __OP_SPACETOBATCHND_H__ - -#include "OpChef.h" - -class SpaceToBatchNDChef final : public OpChef -{ -public: - explicit SpaceToBatchNDChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_SPACE_TO_BATCH_ND; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_SpaceToBatchNDOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SpaceToBatchNDChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SPACETOBATCHND_H__ diff --git a/compiler/tflchef/core/src/Op/SpaceToDepth.cpp b/compiler/tflchef/core/src/Op/SpaceToDepth.cpp deleted file mode 100644 index 98eed8c26..000000000 --- a/compiler/tflchef/core/src/Op/SpaceToDepth.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SpaceToDepth.h" - -#include <cassert> - -flatbuffers::Offset<void> SpaceToDepthChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_space_to_depth_options()); - - auto tflite_block_size = operation.space_to_depth_options().block_size(); - - tflite::SpaceToDepthOptionsBuilder std_options_builder{fbb}; - std_options_builder.add_block_size(tflite_block_size); - - return std_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SpaceToDepthChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SpaceToDepthChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/SpaceToDepth.h b/compiler/tflchef/core/src/Op/SpaceToDepth.h deleted file mode 100644 index db852feac..000000000 --- a/compiler/tflchef/core/src/Op/SpaceToDepth.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SPACETODEPTH_H__ -#define __OP_SPACETODEPTH_H__ - -#include "OpChef.h" - -class SpaceToDepthChef final : public OpChef -{ -public: - explicit SpaceToDepthChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_SPACE_TO_DEPTH; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_SpaceToDepthOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SpaceToDepthChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SPACETODEPTH_H__ diff --git a/compiler/tflchef/core/src/Op/SparseToDense.cpp b/compiler/tflchef/core/src/Op/SparseToDense.cpp deleted file mode 100644 index f1f8a7150..000000000 --- a/compiler/tflchef/core/src/Op/SparseToDense.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SparseToDense.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> SparseToDenseChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_sparse_to_dense_options()); - - auto tflite_validate_indices = operation.sparse_to_dense_options().validate_indices(); - - tflite::SparseToDenseOptionsBuilder sparse_to_dense_options_builder(fbb); - sparse_to_dense_options_builder.add_validate_indices(tflite_validate_indices); - - return sparse_to_dense_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SparseToDenseChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SparseToDenseChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/SparseToDense.h b/compiler/tflchef/core/src/Op/SparseToDense.h deleted file mode 100644 index 02cbd6a6d..000000000 --- a/compiler/tflchef/core/src/Op/SparseToDense.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SPARSETODENSE_H__ -#define __OP_SPARSETODENSE_H__ - -#include "OpChef.h" - -class SparseToDenseChef final : public OpChef -{ -public: - explicit SparseToDenseChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_SPARSE_TO_DENSE; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_SparseToDenseOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SparseToDenseChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SPARSETODENSE_H__ diff --git a/compiler/tflchef/core/src/Op/Split.cpp b/compiler/tflchef/core/src/Op/Split.cpp deleted file mode 100644 index f4704e537..000000000 --- a/compiler/tflchef/core/src/Op/Split.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Split.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> SplitChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_split_options()); - - auto num_splits = operation.split_options().num_splits(); - - tflite::SplitOptionsBuilder split_options_builder{fbb}; - split_options_builder.add_num_splits(num_splits); - - return split_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SplitChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SplitChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Split.h b/compiler/tflchef/core/src/Op/Split.h deleted file mode 100644 index db6158069..000000000 --- a/compiler/tflchef/core/src/Op/Split.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SPLIT_H__ -#define __OP_SPLIT_H__ - -#include "OpChef.h" - -class SplitChef final : public OpChef -{ -public: - explicit SplitChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SPLIT; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_SplitOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SplitChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SPLIT_H__ diff --git a/compiler/tflchef/core/src/Op/SplitV.cpp b/compiler/tflchef/core/src/Op/SplitV.cpp deleted file mode 100644 index fa93db6ba..000000000 --- a/compiler/tflchef/core/src/Op/SplitV.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SplitV.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> SplitVChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_split_v_options()); - - auto num_splits = operation.split_v_options().num_splits(); - - tflite::SplitVOptionsBuilder split_v_options_builder{fbb}; - split_v_options_builder.add_num_splits(num_splits); - - return split_v_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SplitVChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SplitVChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/SplitV.h b/compiler/tflchef/core/src/Op/SplitV.h deleted file mode 100644 index c37736e31..000000000 --- a/compiler/tflchef/core/src/Op/SplitV.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SPLIT_V_H__ -#define __OP_SPLIT_V_H__ - -#include "OpChef.h" - -class SplitVChef final : public OpChef -{ -public: - explicit SplitVChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SPLIT_V; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_SplitVOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SplitVChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SPLIT_V_H__ diff --git a/compiler/tflchef/core/src/Op/Square.cpp b/compiler/tflchef/core/src/Op/Square.cpp deleted file mode 100644 index fd3538072..000000000 --- a/compiler/tflchef/core/src/Op/Square.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Square.h" - -flatbuffers::Offset<void> SquareChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::SquareOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SquareChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SquareChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Square.h b/compiler/tflchef/core/src/Op/Square.h deleted file mode 100644 index 5b76e6302..000000000 --- a/compiler/tflchef/core/src/Op/Square.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SQUARE_H__ -#define __OP_SQUARE_H__ - -#include "OpChef.h" - -class SquareChef final : public OpChef -{ -public: - explicit SquareChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SQUARE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_SquareOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SquareChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SQUARE_H__ diff --git a/compiler/tflchef/core/src/Op/SquaredDifference.cpp b/compiler/tflchef/core/src/Op/SquaredDifference.cpp deleted file mode 100644 index 757c148a9..000000000 --- a/compiler/tflchef/core/src/Op/SquaredDifference.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SquaredDifference.h" - -flatbuffers::Offset<void> SquaredDifferenceChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::SquaredDifferenceOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> -SquaredDifferenceChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SquaredDifferenceChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/SquaredDifference.h b/compiler/tflchef/core/src/Op/SquaredDifference.h deleted file mode 100644 index f919975f9..000000000 --- a/compiler/tflchef/core/src/Op/SquaredDifference.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SQUAREDDIFFERENCE_H__ -#define __OP_SQUAREDDIFFERENCE_H__ - -#include "OpChef.h" - -class SquaredDifferenceChef final : public OpChef -{ -public: - explicit SquaredDifferenceChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_SQUARED_DIFFERENCE; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_SquaredDifferenceOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SquaredDifferenceChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SQUAREDDIFFERENCE_H__ diff --git a/compiler/tflchef/core/src/Op/Squeeze.cpp b/compiler/tflchef/core/src/Op/Squeeze.cpp deleted file mode 100644 index 8d6ef42d6..000000000 --- a/compiler/tflchef/core/src/Op/Squeeze.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Squeeze.h" -#include "Convert.h" - -#include <cassert> -#include <vector> - -flatbuffers::Offset<void> SqueezeChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_squeeze_options()); - - const auto &options = operation.squeeze_options(); - // Note: 'CreateVector' should be placed before 'CreateOptions' - // Read flatbuffers.h 'void NotNested()' for more information - auto fb_squeeze_dims = - fbb.CreateVector(options.squeeze_dim().data(), options.squeeze_dim().size()); - - return tflite::CreateSqueezeOptions(fbb, fb_squeeze_dims).Union(); -} - -std::unique_ptr<OpChef> SqueezeChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SqueezeChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Squeeze.h b/compiler/tflchef/core/src/Op/Squeeze.h deleted file mode 100644 index 2787231f2..000000000 --- a/compiler/tflchef/core/src/Op/Squeeze.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SQUEEZE_H__ -#define __OP_SQUEEZE_H__ - -#include "OpChef.h" - -class SqueezeChef final : public OpChef -{ -public: - explicit SqueezeChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SQUEEZE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_SqueezeOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SqueezeChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SQUEEZE_H__ diff --git a/compiler/tflchef/core/src/Op/StridedSlice.cpp b/compiler/tflchef/core/src/Op/StridedSlice.cpp deleted file mode 100644 index 587a95c66..000000000 --- a/compiler/tflchef/core/src/Op/StridedSlice.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "StridedSlice.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> StridedSliceChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_strided_slice_options()); - - tflite::StridedSliceOptionsBuilder strided_slice_options_builder{fbb}; - strided_slice_options_builder.add_begin_mask(operation.strided_slice_options().begin_mask()); - strided_slice_options_builder.add_end_mask(operation.strided_slice_options().end_mask()); - strided_slice_options_builder.add_ellipsis_mask( - operation.strided_slice_options().ellipsis_mask()); - strided_slice_options_builder.add_new_axis_mask( - operation.strided_slice_options().new_axis_mask()); - strided_slice_options_builder.add_shrink_axis_mask( - operation.strided_slice_options().shrink_axis_mask()); - - return strided_slice_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> StridedSliceChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new StridedSliceChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/StridedSlice.h b/compiler/tflchef/core/src/Op/StridedSlice.h deleted file mode 100644 index 49da44f12..000000000 --- a/compiler/tflchef/core/src/Op/StridedSlice.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_STRIDEDSLICE_H__ -#define __OP_STRIDEDSLICE_H__ - -#include "OpChef.h" - -class StridedSliceChef final : public OpChef -{ -public: - explicit StridedSliceChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_STRIDED_SLICE; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_StridedSliceOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct StridedSliceChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_STRIDEDSLICE_H__ diff --git a/compiler/tflchef/core/src/Op/Sum.cpp b/compiler/tflchef/core/src/Op/Sum.cpp deleted file mode 100644 index 6b79d3ec5..000000000 --- a/compiler/tflchef/core/src/Op/Sum.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Sum.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> SumChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_sum_options()); - - auto keep_dims = operation.sum_options().keep_dims(); - - tflite::ReducerOptionsBuilder sum_options_builder{fbb}; - sum_options_builder.add_keep_dims(keep_dims); - - return sum_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> SumChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new SumChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Sum.h b/compiler/tflchef/core/src/Op/Sum.h deleted file mode 100644 index d3cc8c173..000000000 --- a/compiler/tflchef/core/src/Op/Sum.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_SUM_H__ -#define __OP_SUM_H__ - -#include "OpChef.h" - -class SumChef final : public OpChef -{ -public: - explicit SumChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SUM; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_ReducerOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct SumChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_SUM_H__ diff --git a/compiler/tflchef/core/src/Op/Tanh.cpp b/compiler/tflchef/core/src/Op/Tanh.cpp deleted file mode 100644 index c25cad8f0..000000000 --- a/compiler/tflchef/core/src/Op/Tanh.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Tanh.h" - -flatbuffers::Offset<void> TanhChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - // No tflite option for Tanh. Use void. - return flatbuffers::Offset<void>(); -} - -std::unique_ptr<OpChef> TanhChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new TanhChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Tanh.h b/compiler/tflchef/core/src/Op/Tanh.h deleted file mode 100644 index f8f707a04..000000000 --- a/compiler/tflchef/core/src/Op/Tanh.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_TANH_H__ -#define __OP_TANH_H__ - -#include "OpChef.h" - -class TanhChef final : public OpChef -{ -public: - explicit TanhChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_TANH; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct TanhChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_TANH_H__ diff --git a/compiler/tflchef/core/src/Op/Tile.cpp b/compiler/tflchef/core/src/Op/Tile.cpp deleted file mode 100644 index 18710b4b0..000000000 --- a/compiler/tflchef/core/src/Op/Tile.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Tile.h" - -flatbuffers::Offset<void> TileChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::TileOptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> TileChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new TileChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Tile.h b/compiler/tflchef/core/src/Op/Tile.h deleted file mode 100644 index 2870ff174..000000000 --- a/compiler/tflchef/core/src/Op/Tile.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_TILE_H__ -#define __OP_TILE_H__ - -#include "OpChef.h" - -class TileChef final : public OpChef -{ -public: - explicit TileChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_TILE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_TileOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct TileChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_TILE_H__ diff --git a/compiler/tflchef/core/src/Op/TopKV2.cpp b/compiler/tflchef/core/src/Op/TopKV2.cpp deleted file mode 100644 index 08c4de66b..000000000 --- a/compiler/tflchef/core/src/Op/TopKV2.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "TopKV2.h" - -flatbuffers::Offset<void> TopKV2Chef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::TopKV2OptionsBuilder options_builder{fbb}; - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> TopKV2ChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new TopKV2Chef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/TopKV2.h b/compiler/tflchef/core/src/Op/TopKV2.h deleted file mode 100644 index 554822332..000000000 --- a/compiler/tflchef/core/src/Op/TopKV2.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_TOPK_V2_H__ -#define __OP_TOPK_V2_H__ - -#include "OpChef.h" - -class TopKV2Chef final : public OpChef -{ -public: - explicit TopKV2Chef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_TOPK_V2; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_TopKV2Options; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct TopKV2ChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_TOPK_V2_H__ diff --git a/compiler/tflchef/core/src/Op/Transpose.cpp b/compiler/tflchef/core/src/Op/Transpose.cpp deleted file mode 100644 index caae6cfa8..000000000 --- a/compiler/tflchef/core/src/Op/Transpose.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Transpose.h" -#include "Convert.h" - -#include <cassert> -#include <vector> - -flatbuffers::Offset<void> TransposeChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::TransposeOptionsBuilder options_builder{fbb}; - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> TransposeChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new TransposeChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Transpose.h b/compiler/tflchef/core/src/Op/Transpose.h deleted file mode 100644 index bb30f7bc9..000000000 --- a/compiler/tflchef/core/src/Op/Transpose.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_TRANSPOSE_H__ -#define __OP_TRANSPOSE_H__ - -#include "OpChef.h" - -class TransposeChef final : public OpChef -{ -public: - explicit TransposeChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_TRANSPOSE; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_TransposeOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct TransposeChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_TRANSPOSE_H__ diff --git a/compiler/tflchef/core/src/Op/TransposeConv.cpp b/compiler/tflchef/core/src/Op/TransposeConv.cpp deleted file mode 100644 index c9e452714..000000000 --- a/compiler/tflchef/core/src/Op/TransposeConv.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "TransposeConv.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> TransposeConvChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - tflite::TransposeConvOptionsBuilder options_builder{fbb}; - - assert(operation.has_transpose_conv_options()); - - auto tflite_padding = as_tflite_padding(operation.transpose_conv_options().padding()); - - options_builder.add_padding(tflite_padding); - - options_builder.add_stride_h(operation.transpose_conv_options().stride_h()); - options_builder.add_stride_w(operation.transpose_conv_options().stride_w()); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> TransposeConvChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new TransposeConvChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/TransposeConv.h b/compiler/tflchef/core/src/Op/TransposeConv.h deleted file mode 100644 index e664bfff2..000000000 --- a/compiler/tflchef/core/src/Op/TransposeConv.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_TRANSPOSE_CONV_H__ -#define __OP_TRANSPOSE_CONV_H__ - -#include "OpChef.h" - -class TransposeConvChef final : public OpChef -{ -public: - explicit TransposeConvChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_TRANSPOSE_CONV; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_TransposeConvOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct TransposeConvChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_TRANSPOSE_CONV_H__ diff --git a/compiler/tflchef/core/src/Op/UnidirectionalSequenceLSTM.cpp b/compiler/tflchef/core/src/Op/UnidirectionalSequenceLSTM.cpp deleted file mode 100644 index ceabfc13c..000000000 --- a/compiler/tflchef/core/src/Op/UnidirectionalSequenceLSTM.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "UnidirectionalSequenceLSTM.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> -UnidirectionalSequenceLSTMChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_unidirectional_sequence_lstm_options()); - - tflite::UnidirectionalSequenceLSTMOptionsBuilder options_builder(fbb); - options_builder.add_fused_activation_function( - as_tflite_activation(operation.unidirectional_sequence_lstm_options().activation())); - options_builder.add_cell_clip(operation.unidirectional_sequence_lstm_options().cell_clip()); - options_builder.add_proj_clip(operation.unidirectional_sequence_lstm_options().proj_clip()); - options_builder.add_time_major(operation.unidirectional_sequence_lstm_options().time_major()); - options_builder.add_asymmetric_quantize_inputs( - operation.unidirectional_sequence_lstm_options().asymmetric_quantize_inputs()); - - return options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> -UnidirectionalSequenceLSTMChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new UnidirectionalSequenceLSTMChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/UnidirectionalSequenceLSTM.h b/compiler/tflchef/core/src/Op/UnidirectionalSequenceLSTM.h deleted file mode 100644 index 6811ad378..000000000 --- a/compiler/tflchef/core/src/Op/UnidirectionalSequenceLSTM.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_UNIDIRECTIONALSEQUENCELSTM_H__ -#define __OP_UNIDIRECTIONALSEQUENCELSTM_H__ - -#include "OpChef.h" - -class UnidirectionalSequenceLSTMChef final : public OpChef -{ -public: - explicit UnidirectionalSequenceLSTMChef(const tflchef::Operation *operation) - : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override - { - return tflite::BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_LSTM; - } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_UnidirectionalSequenceLSTMOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct UnidirectionalSequenceLSTMChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_UNIDIRECTIONALSEQUENCELSTM_H__ diff --git a/compiler/tflchef/core/src/Op/Unique.cpp b/compiler/tflchef/core/src/Op/Unique.cpp deleted file mode 100644 index d9a7293c5..000000000 --- a/compiler/tflchef/core/src/Op/Unique.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Unique.h" -#include "Convert.h" - -#include <cassert> - -flatbuffers::Offset<void> UniqueChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_unique_options()); - - auto tflite_out_idx = as_tflite_tensortype(operation.unique_options().idx_out_type()); - - tflite::UniqueOptionsBuilder unique_options_builder{fbb}; - unique_options_builder.add_idx_out_type(tflite_out_idx); - - return unique_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> UniqueChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new UniqueChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Unique.h b/compiler/tflchef/core/src/Op/Unique.h deleted file mode 100644 index 58aa7bfaa..000000000 --- a/compiler/tflchef/core/src/Op/Unique.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_UNIQUE_H__ -#define __OP_UNIQUE_H__ - -#include "OpChef.h" - -class UniqueChef final : public OpChef -{ -public: - explicit UniqueChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_UNIQUE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_UniqueOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct UniqueChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_UNIQUE_H__ diff --git a/compiler/tflchef/core/src/Op/Unpack.cpp b/compiler/tflchef/core/src/Op/Unpack.cpp deleted file mode 100644 index 504da5a46..000000000 --- a/compiler/tflchef/core/src/Op/Unpack.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Unpack.h" - -flatbuffers::Offset<void> UnpackChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_unpack_options()); - - tflite::UnpackOptionsBuilder unpack_options_builder{fbb}; - unpack_options_builder.add_num(operation.unpack_options().num()); - unpack_options_builder.add_axis(operation.unpack_options().axis()); - - return unpack_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> UnpackChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new UnpackChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Unpack.h b/compiler/tflchef/core/src/Op/Unpack.h deleted file mode 100644 index 3a425b1a3..000000000 --- a/compiler/tflchef/core/src/Op/Unpack.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_UNPACK_H__ -#define __OP_UNPACK_H__ - -#include "OpChef.h" - -class UnpackChef final : public OpChef -{ -public: - explicit UnpackChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_UNPACK; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_UnpackOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct UnpackChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ABS_H__ diff --git a/compiler/tflchef/core/src/Op/Where.cpp b/compiler/tflchef/core/src/Op/Where.cpp deleted file mode 100644 index 0ce9102bc..000000000 --- a/compiler/tflchef/core/src/Op/Where.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 specwhileic language governing permissions and - * limitations under the License. - */ - -#include "Where.h" - -flatbuffers::Offset<void> WhereChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::WhereOptionsBuilder where_options_builder{fbb}; - return where_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> WhereChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new WhereChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/Where.h b/compiler/tflchef/core/src/Op/Where.h deleted file mode 100644 index 7991c64cd..000000000 --- a/compiler/tflchef/core/src/Op/Where.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_WHERE_H__ -#define __OP_WHERE_H__ - -#include "OpChef.h" - -class WhereChef final : public OpChef -{ -public: - explicit WhereChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_WHERE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_WhereOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct WhereChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_WHERE_H__ diff --git a/compiler/tflchef/core/src/Op/While.cpp b/compiler/tflchef/core/src/Op/While.cpp deleted file mode 100644 index 1253d0fcc..000000000 --- a/compiler/tflchef/core/src/Op/While.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 specwhileic language governing permissions and - * limitations under the License. - */ - -#include "While.h" - -flatbuffers::Offset<void> WhileChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - auto &operation = (*_operation); - - assert(operation.has_while_options()); - - tflite::WhileOptionsBuilder while_options_builder{fbb}; - while_options_builder.add_cond_subgraph_index(operation.while_options().cond_subgraph_index()); - while_options_builder.add_body_subgraph_index(operation.while_options().body_subgraph_index()); - - return while_options_builder.Finish().Union(); -} - -std::unique_ptr<OpChef> WhileChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new WhileChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/While.h b/compiler/tflchef/core/src/Op/While.h deleted file mode 100644 index 150a14be3..000000000 --- a/compiler/tflchef/core/src/Op/While.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_WHILE_H__ -#define __OP_WHILE_H__ - -#include "OpChef.h" - -class WhileChef final : public OpChef -{ -public: - explicit WhileChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_WHILE; } - - tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_WhileOptions; } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct WhileChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_WHILE_H__ diff --git a/compiler/tflchef/core/src/Op/ZerosLike.cpp b/compiler/tflchef/core/src/Op/ZerosLike.cpp deleted file mode 100644 index e47e2ab50..000000000 --- a/compiler/tflchef/core/src/Op/ZerosLike.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ZerosLike.h" - -flatbuffers::Offset<void> ZerosLikeChef::value(flatbuffers::FlatBufferBuilder &fbb) const -{ - tflite::ZerosLikeOptionsBuilder builder{fbb}; - return builder.Finish().Union(); -} - -std::unique_ptr<OpChef> ZerosLikeChefFactory::create(const tflchef::Operation *operation) const -{ - return std::unique_ptr<OpChef>{new ZerosLikeChef{operation}}; -} diff --git a/compiler/tflchef/core/src/Op/ZerosLike.h b/compiler/tflchef/core/src/Op/ZerosLike.h deleted file mode 100644 index 0af5b93e2..000000000 --- a/compiler/tflchef/core/src/Op/ZerosLike.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __OP_ZEROS_LIKE_H__ -#define __OP_ZEROS_LIKE_H__ - -#include "OpChef.h" - -class ZerosLikeChef final : public OpChef -{ -public: - explicit ZerosLikeChef(const tflchef::Operation *operation) : _operation{operation} - { - // DO NOTHING - } - -public: - tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_ZEROS_LIKE; } - - tflite::BuiltinOptions type(void) const override - { - return tflite::BuiltinOptions_ZerosLikeOptions; - } - - flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; - -private: - const tflchef::Operation *_operation; -}; - -struct ZerosLikeChefFactory final : public OpChefFactory -{ - std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override; -}; - -#endif // __OP_ZEROS_LIKE_H__ diff --git a/compiler/tflchef/core/src/OpChef.def b/compiler/tflchef/core/src/OpChef.def index f2755fc29..cd34c7202 100644 --- a/compiler/tflchef/core/src/OpChef.def +++ b/compiler/tflchef/core/src/OpChef.def @@ -4,118 +4,15 @@ // Please keep the list in alphabetical order // OP_CHEF(NAME, FACTORY_CLASS) -OP_CHEF(Abs, AbsChefFactory) -OP_CHEF(Add, AddChefFactory) -OP_CHEF(AddN, AddNChefFactory) -OP_CHEF(ArgMax, ArgMaxChefFactory) -OP_CHEF(ArgMin, ArgMinChefFactory) OP_CHEF(AveragePool2D, AveragePool2DChefFactory) -OP_CHEF(BatchMatMul, BatchMatMulChefFactory) -OP_CHEF(BatchToSpaceND, BatchToSpaceNDChefFactory) -OP_CHEF(Cast, CastChefFactory) -OP_CHEF(Ceil, CeilChefFactory) OP_CHEF(Concatenation, ConcatenationChefFactory) OP_CHEF(Conv2D, Conv2DChefFactory) -OP_CHEF(Cos, CosChefFactory) -OP_CHEF(DepthToSpace, DepthToSpaceChefFactory) OP_CHEF(DepthwiseConv2D, DepthwiseConv2DChefFactory) -OP_CHEF(Dequantize, DequantizeChefFactory) OP_CHEF(Div, DivChefFactory) -OP_CHEF(ELU, ELUChefFactory) -OP_CHEF(Equal, EqualChefFactory) -OP_CHEF(Exp, ExpChefFactory) -OP_CHEF(ExpandDims, ExpandDimsChefFactory) -OP_CHEF(Fill, FillChefFactory) -OP_CHEF(Floor, FloorChefFactory) -OP_CHEF(FloorDiv, FloorDivChefFactory) -OP_CHEF(FloorMod, FloorModChefFactory) OP_CHEF(FullyConnected, FullyConnectedChefFactory) -OP_CHEF(Gather, GatherChefFactory) -OP_CHEF(GatherNd, GatherNdChefFactory) -OP_CHEF(Greater, GreaterChefFactory) -OP_CHEF(GreaterEqual, GreaterEqualChefFactory) -OP_CHEF(If, IfChefFactory) -OP_CHEF(L2Normalize, L2NormalizeChefFactory) -OP_CHEF(L2Pool2D, L2Pool2DChefFactory) -OP_CHEF(LeakyRelu, LeakyReluChefFactory) -OP_CHEF(Less, LessChefFactory) -OP_CHEF(LessEqual, LessEqualChefFactory) -OP_CHEF(LocalResponseNormalization, LocalResponseNormalizationChefFactory) -OP_CHEF(Log, LogChefFactory) -OP_CHEF(LogicalAnd, LogicalAndChefFactory) -OP_CHEF(LogicalNot, LogicalNotChefFactory) -OP_CHEF(LogicalOr, LogicalOrChefFactory) -OP_CHEF(Logistic, LogisticChefFactory) -OP_CHEF(LogSoftmax, LogSoftmaxChefFactory) -OP_CHEF(MatrixDiag, MatrixDiagChefFactory) -OP_CHEF(MatrixSetDiag, MatrixSetDiagChefFactory) -OP_CHEF(Maximum, MaximumChefFactory) OP_CHEF(MaxPool2D, MaxPool2DChefFactory) -OP_CHEF(Mean, MeanChefFactory) -OP_CHEF(Minimum, MinimumChefFactory) -OP_CHEF(MirrorPad, MirrorPadChefFactory) -OP_CHEF(Mul, MulChefFactory) -OP_CHEF(Neg, NegChefFactory) -OP_CHEF(NonMaxSuppressionV4, NonMaxSuppressionV4ChefFactory) -OP_CHEF(NonMaxSuppressionV5, NonMaxSuppressionV5ChefFactory) -OP_CHEF(NotEqual, NotEqualChefFactory) -OP_CHEF(OneHot, OneHotChefFactory) -OP_CHEF(Pack, PackChefFactory) -OP_CHEF(Pad, PadChefFactory) -OP_CHEF(PadV2, PadV2ChefFactory) -OP_CHEF(Pow, PowChefFactory) -OP_CHEF(PRelu, PReluChefFactory) -OP_CHEF(Range, RangeChefFactory) -OP_CHEF(Rank, RankChefFactory) -OP_CHEF(ReduceAny, ReduceAnyChefFactory) -OP_CHEF(ReduceMax, ReduceMaxChefFactory) -OP_CHEF(ReduceMin, ReduceMinChefFactory) -OP_CHEF(ReduceProd, ReduceProdChefFactory) OP_CHEF(ReLU, ReLUChefFactory) OP_CHEF(ReLU6, ReLU6ChefFactory) -OP_CHEF(ReLUN1To1, ReLUN1To1ChefFactory) OP_CHEF(Reshape, ReshapeChefFactory) -OP_CHEF(ResizeBilinear, ResizeBilinearChefFactory) -OP_CHEF(ResizeNearestNeighbor, ResizeNearestNeighborChefFactory) -OP_CHEF(ReverseSequence, ReverseSequenceChefFactory) -OP_CHEF(ReverseV2, ReverseV2ChefFactory) -OP_CHEF(Round, RoundChefFactory) -OP_CHEF(Rsqrt, RsqrtChefFactory) -OP_CHEF(ScatterNd, ScatterNdChefFactory) -OP_CHEF(SegmentSum,SegmentSumChefFactory) -OP_CHEF(Select, SelectChefFactory) -OP_CHEF(SelectV2, SelectV2ChefFactory) -OP_CHEF(Shape, ShapeChefFactory) -OP_CHEF(Sin, SinChefFactory) -OP_CHEF(Slice, SliceChefFactory) -OP_CHEF(Softmax, SoftmaxChefFactory) -OP_CHEF(SpaceToBatchND, SpaceToBatchNDChefFactory) -OP_CHEF(SpaceToDepth, SpaceToDepthChefFactory) -OP_CHEF(SparseToDense, SparseToDenseChefFactory) -OP_CHEF(Split, SplitChefFactory) -OP_CHEF(SplitV, SplitVChefFactory) OP_CHEF(Sqrt, SqrtChefFactory) -OP_CHEF(Square, SquareChefFactory) -OP_CHEF(SquaredDifference, SquaredDifferenceChefFactory) -OP_CHEF(Squeeze, SqueezeChefFactory) -OP_CHEF(StridedSlice, StridedSliceChefFactory) OP_CHEF(Sub, SubChefFactory) -OP_CHEF(Sum, SumChefFactory) -OP_CHEF(Tanh, TanhChefFactory) -OP_CHEF(Tile, TileChefFactory) -OP_CHEF(TopKV2, TopKV2ChefFactory) -OP_CHEF(Transpose, TransposeChefFactory) -OP_CHEF(TransposeConv, TransposeConvChefFactory) -OP_CHEF(UnidirectionalSequenceLSTM, UnidirectionalSequenceLSTMChefFactory) -OP_CHEF(Unique, UniqueChefFactory) -OP_CHEF(Unpack, UnpackChefFactory) -OP_CHEF(Where, WhereChefFactory) -OP_CHEF(While, WhileChefFactory) -OP_CHEF(ZerosLike, ZerosLikeChefFactory) - -// Custom Op -OP_CHEF(AddV2, AddV2ChefFactory) -OP_CHEF(All, AllChefFactory) -OP_CHEF(BatchMatMulV2, BatchMatMulV2ChefFactory) -OP_CHEF(MatMul, MatMulChefFactory) -OP_CHEF(MatrixBandPart, MatrixBandPartChefFactory) diff --git a/compiler/tflchef/core/src/OpChef.h b/compiler/tflchef/core/src/OpChef.h index 7efa096cc..5290fec8b 100644 --- a/compiler/tflchef/core/src/OpChef.h +++ b/compiler/tflchef/core/src/OpChef.h @@ -18,7 +18,7 @@ #define __OP_CHEF_H__ #include <tflchef.pb.h> -#include <mio/tflite/schema_generated.h> +#include <tflite_generated.h> #include <memory> @@ -29,13 +29,6 @@ struct OpChef virtual tflite::BuiltinOperator code(void) const = 0; virtual tflite::BuiltinOptions type(void) const = 0; virtual flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const = 0; - - // TODO Find a way to place this method in a better place - virtual flatbuffers::Offset<flatbuffers::Vector<uint8_t>> - custom_value(flatbuffers::FlatBufferBuilder &fbb) const - { - return flatbuffers::Offset<flatbuffers::Vector<uint8_t>>(); - } }; struct OpChefFactory diff --git a/compiler/tflchef/core/src/OpChefs.h b/compiler/tflchef/core/src/OpChefs.h index 36b9bdb76..5e0f4aa71 100644 --- a/compiler/tflchef/core/src/OpChefs.h +++ b/compiler/tflchef/core/src/OpChefs.h @@ -17,119 +17,17 @@ #ifndef __OP_CHEFS_H__ #define __OP_CHEFS_H__ -#include "Op/Abs.h" -#include "Op/Add.h" -#include "Op/AddN.h" -#include "Op/ArgMax.h" -#include "Op/ArgMin.h" #include "Op/AveragePool2D.h" -#include "Op/BatchMatMul.h" -#include "Op/BatchToSpaceND.h" -#include "Op/Cast.h" -#include "Op/Ceil.h" #include "Op/Concatenation.h" #include "Op/Conv2D.h" -#include "Op/Cos.h" -#include "Op/DepthToSpace.h" #include "Op/DepthwiseConv2D.h" -#include "Op/Dequantize.h" #include "Op/Div.h" -#include "Op/ELU.h" -#include "Op/Equal.h" -#include "Op/Exp.h" -#include "Op/ExpandDims.h" -#include "Op/Fill.h" -#include "Op/Floor.h" -#include "Op/FloorDiv.h" -#include "Op/FloorMod.h" #include "Op/FullyConnected.h" -#include "Op/Gather.h" -#include "Op/GatherNd.h" -#include "Op/Greater.h" -#include "Op/GreaterEqual.h" -#include "Op/If.h" -#include "Op/L2Normalize.h" -#include "Op/L2Pool2D.h" -#include "Op/LeakyRelu.h" -#include "Op/Less.h" -#include "Op/LessEqual.h" -#include "Op/LocalResponseNormalization.h" -#include "Op/Log.h" -#include "Op/LogicalAnd.h" -#include "Op/LogicalNot.h" -#include "Op/LogicalOr.h" -#include "Op/Logistic.h" -#include "Op/LogSoftmax.h" -#include "Op/MatrixDiag.h" -#include "Op/MatrixSetDiag.h" -#include "Op/Maximum.h" #include "Op/MaxPool2D.h" -#include "Op/Mean.h" -#include "Op/Minimum.h" -#include "Op/MirrorPad.h" -#include "Op/Mul.h" -#include "Op/Neg.h" -#include "Op/NonMaxSuppressionV4.h" -#include "Op/NonMaxSuppressionV5.h" -#include "Op/NotEqual.h" -#include "Op/OneHot.h" -#include "Op/Pack.h" -#include "Op/Pad.h" -#include "Op/PadV2.h" -#include "Op/Pow.h" -#include "Op/PRelu.h" -#include "Op/Range.h" -#include "Op/Rank.h" -#include "Op/ReduceAny.h" -#include "Op/ReduceMax.h" -#include "Op/ReduceMin.h" -#include "Op/ReduceProd.h" #include "Op/ReLU.h" #include "Op/ReLU6.h" -#include "Op/ReLUN1To1.h" #include "Op/Reshape.h" -#include "Op/ResizeBilinear.h" -#include "Op/ResizeNearestNeighbor.h" -#include "Op/ReverseSequence.h" -#include "Op/ReverseV2.h" -#include "Op/Round.h" -#include "Op/Rsqrt.h" -#include "Op/ScatterNd.h" -#include "Op/SegmentSum.h" -#include "Op/Select.h" -#include "Op/SelectV2.h" -#include "Op/Shape.h" -#include "Op/Sin.h" -#include "Op/Slice.h" -#include "Op/Softmax.h" -#include "Op/SpaceToBatchND.h" -#include "Op/SpaceToDepth.h" -#include "Op/SparseToDense.h" -#include "Op/Split.h" -#include "Op/SplitV.h" #include "Op/Sqrt.h" -#include "Op/Square.h" -#include "Op/SquaredDifference.h" -#include "Op/Squeeze.h" -#include "Op/StridedSlice.h" #include "Op/Sub.h" -#include "Op/Sum.h" -#include "Op/Tanh.h" -#include "Op/Tile.h" -#include "Op/TopKV2.h" -#include "Op/Transpose.h" -#include "Op/TransposeConv.h" -#include "Op/UnidirectionalSequenceLSTM.h" -#include "Op/Unique.h" -#include "Op/Unpack.h" -#include "Op/Where.h" -#include "Op/While.h" -#include "Op/ZerosLike.h" - -#include "CustomOp/AddV2.h" -#include "CustomOp/All.h" -#include "CustomOp/BatchMatMulV2.h" -#include "CustomOp/MatMul.h" -#include "CustomOp/MatrixBandPart.h" #endif // __OP_CHEFS_H__ diff --git a/compiler/tflchef/log/CMakeLists.txt b/compiler/tflchef/log/CMakeLists.txt deleted file mode 100644 index 330459ec1..000000000 --- a/compiler/tflchef/log/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# TODO Find how to test logging framework -file(GLOB_RECURSE SOURCES "src/*.cpp") - -add_library(tflchef_log STATIC ${SOURCES}) -target_include_directories(tflchef_log PUBLIC include) -target_link_libraries(tflchef_log PUBLIC hermes) -target_link_libraries(tflchef_log PRIVATE hermes_std) diff --git a/compiler/tflchef/log/include/Log.h b/compiler/tflchef/log/include/Log.h deleted file mode 100644 index 178fe31c4..000000000 --- a/compiler/tflchef/log/include/Log.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLCHEF_LOG_H__ -#define __TFLCHEF_LOG_H__ - -#include <hermes.h> - -namespace tflchef -{ - -/** - * @brief Logger Implementation - */ -class Logger final : public hermes::Source -{ -public: - Logger(hermes::Context *ctx); - ~Logger(); -}; - -/** - * @brief Logger Configuration - * - * Users are able to turn logging on/off via TFLCHEF_LOG environment variable. - */ -class LoggerConfig final : public hermes::Config -{ -public: - LoggerConfig(); - -public: - void configure(const hermes::Source *, hermes::Source::Setting &) const final; - void configure(const Logger *, hermes::Source::Setting &) const; - -private: - bool _enabled; -}; - -} // namespace tflchef - -#include "LoggingContext.h" - -/** - * HOW TO USE: - * - * LOGGER(l); - * - * INFO(l) << "Hello, World" << std::endl; - * - */ -#define LOGGER(name) ::tflchef::Logger name{::tflchef::LoggingContext::get()}; - -// TODO Support FATAL, ERROR, WARN, and VERBOSE -#define INFO(name) HERMES_INFO(name) - -// WARNING! -// -// THE CURRENT IMPLEMENTATION IS NOT THREAD SAFE. -// - -#endif // __TFLCHEF_LOG_H__ diff --git a/compiler/tflchef/log/src/Log.cpp b/compiler/tflchef/log/src/Log.cpp deleted file mode 100644 index 62c377745..000000000 --- a/compiler/tflchef/log/src/Log.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Log.h" - -#include <cassert> -#include <cstdlib> -#include <iostream> - -// TODO Extract these lexical conversion routines as a library -namespace -{ - -/** - * @brief Convert C-string as a value of type T - * - * safecast(s, v) returns v if s is nullptr. - */ -template <typename T> T safecast(const char *, const T &); - -template <> bool safecast<bool>(const char *s, const bool &value) -{ - return (s == nullptr) ? value : (std::stoi(s) != 0); -} - -} // namespace - -// -// Logger -// -namespace tflchef -{ - -Logger::Logger(hermes::Context *ctx) { activate(ctx->sources(), ctx->bus()); } -Logger::~Logger() { deactivate(); } - -} // namespace tflchef - -// -// LoggerConfig -// -namespace tflchef -{ - -LoggerConfig::LoggerConfig() -{ - // Turn on logging if TFLCHEF_LOG is set as non-zero value - _enabled = safecast<bool>(std::getenv("TFLCHEF_LOG"), false); -} - -void LoggerConfig::configure(const hermes::Source *source, hermes::Source::Setting &setting) const -{ - // Let's ignore hermes::Sources if that is not a moco logger - if (auto logger = dynamic_cast<const Logger *>(source)) - { - configure(logger, setting); - } -} - -void LoggerConfig::configure(const Logger *, hermes::Source::Setting &setting) const -{ - if (_enabled) - { - // Enable all catagories - setting.accept_all(); - } - else - { - // Disable all catagories - setting.reject_all(); - } -} - -} // namespace tflchef diff --git a/compiler/tflchef/proto/tflchef.proto b/compiler/tflchef/proto/tflchef.proto index 2efb54c39..dc63f0ca4 100644 --- a/compiler/tflchef/proto/tflchef.proto +++ b/compiler/tflchef/proto/tflchef.proto @@ -2,35 +2,10 @@ syntax = "proto2"; package tflchef; -// -// Initial version -// - Our initial version -// -// Version 1 -// - Backward compatible with Initial version -// - Added Graph to represent sub graphs -// - Added name, version(default as 1), graph in ModelRecipe -// - // This enum value corresponds to TensorType in TensorFlow Lite schema enum TensorType { FLOAT32 = 0; INT32 = 2; - UINT8 = 3; - INT64 = 4; - BOOL = 6; -} - -enum DimensionType { - DENSE = 0; - SPARSE_CSR = 1; -} - -enum SparseIndexVecType { - SparseIdxVecType_NONE = 0; - INT32VEC = 1; - UINT16VEC = 2; - UINT8VEC = 3; } message TensorShape { @@ -47,30 +22,6 @@ message TensorQuantization { repeated float max = 2; repeated float scale = 3; repeated int64 zero_point = 4; - optional int32 quantized_dimension = 5 [default = 0]; -} - -message TensorSparsity { - message TraversalOrder { - repeated int32 dim = 1; - } - message BlockMap { - repeated int32 dim = 1; - } - message IndexVec { - repeated int32 dim = 1; - optional SparseIndexVecType type = 2; - } - message DimMetaData { - optional DimensionType format = 1; - optional int32 dense_size = 2; - optional IndexVec array_segments = 3; - optional IndexVec array_indices = 4; - } - - optional TraversalOrder traversal_order = 1; - optional BlockMap block_map = 2; - repeated DimMetaData dim_metadata = 3; } message Operand { @@ -79,8 +30,6 @@ message Operand { optional TensorShape shape = 3; optional TensorFiller filler = 4; optional TensorQuantization quant = 5; - optional TensorSparsity sparsity = 6; - optional bool is_variable = 7 [default = false]; } // This enum value corresponds to Padding in TensorFlow Lite schema @@ -93,16 +42,7 @@ enum Padding { enum Activation { NONE = 0; RELU = 1; - RELU_N1_TO_1 = 2; RELU6 = 3; - TANH = 4; - SIGN_BIT = 5; -} - -// This enum value corresponds to MirrorPadMode in TensorFlow Lite schema -enum MirrorPadMode { - REFLECT = 0; - SYMMETRIC = 1; } message Conv2DOptions @@ -111,8 +51,6 @@ message Conv2DOptions optional int32 stride_w = 2 [default = 1]; optional int32 stride_h = 3 [default = 1]; optional Activation activation = 4 [default = NONE]; - optional int32 dilation_w_factor = 5 [default = 1]; - optional int32 dilation_h_factor = 6 [default = 1]; } message Pool2DOptions { @@ -140,12 +78,6 @@ message DepthwiseConv2DOptions optional int32 stride_h = 3 [default = 1]; optional int32 depth_multiplier = 4 [default = 1]; optional Activation activation = 5 [default = NONE]; - optional int32 dilation_w_factor = 6 [default = 1]; - optional int32 dilation_h_factor = 7 [default = 1]; -} - -message ScatterNdOptions { - // None } message SubOptions { @@ -156,349 +88,14 @@ message DivOptions { optional Activation activation = 1 [default = NONE]; } -message FloorDivOptions { - // None -} - -message FloorModOptions { - // None -} - message FullyConnectedOptions { optional Activation activation = 1 [default = NONE]; } -message AddOptions { - optional Activation activation = 1 [default = NONE]; -} - -message AddNOptions { - // None -} - -message ArgMaxOptions { - optional TensorType output_type = 1 [default = INT64]; -} - -message ArgMinOptions { - optional TensorType output_type = 1 [default = INT64]; -} - -message PackOptions { - optional int32 values_count = 1; - optional int32 axis = 2 [default = 0]; -} - -message PadOptions { - // None -} - -message PadV2Options { - // None -} - -message MirrorPadOptions { - optional MirrorPadMode mode = 1 [default = REFLECT]; -} - -message SoftmaxOptions { - optional float beta = 1 [default = 0.0]; -} - -message MulOptions { - optional Activation activation = 1 [default = NONE]; -} - -message NegOptions { - // None -} - -message RangeOptions { - // None -} - -message ReducerOptions { - optional bool keep_dims = 1 [ default = false ]; -} - -message SpaceToDepthOptions { - optional int32 block_size = 1; -} - -message LogicalOrOptions { - // None -} - -message LogicalNotOptions { - // None -} - -message LogicalAndOptions { - // None -} - -message TransposeOptions { - // None -} - -message AbsOptions { - // None -} - -message CosOptions { - // None -} - -message EqualOptions { - // None -} - -message ShapeOptions { - optional TensorType out_type = 1 [default = INT32]; -} - -message BatchToSpaceNDOptions { - // None -} - -message SpaceToBatchNDOptions { - // None -} - -message StridedSliceOptions { - optional int32 begin_mask = 1; - optional int32 end_mask = 2; - optional int32 ellipsis_mask = 3; - optional int32 new_axis_mask = 4; - optional int32 shrink_axis_mask = 5; -} - -message SliceOptions { - // None -} - -message ExpOptions { - // None -} - -message ExpandDimsOptions { - // None -} - -message UnpackOptions { - optional int32 num = 1; - optional int32 axis = 2 [default = 0]; -} - -message GatherOptions { - optional int32 axis = 1 [default = 0]; -} - -message TileOptions { - // None -} - -message BatchMatMulOptions { - optional bool adj_x = 1 [default = false]; - optional bool adj_y = 2 [default = false]; -} - -message IfOptions { - optional int32 then_subgraph_index = 1; - optional int32 else_subgraph_index = 2; -} - -message WhileOptions { - optional int32 cond_subgraph_index = 1; - optional int32 body_subgraph_index = 2; -} - -message CastOptions { - optional TensorType in_data_type = 1 [default = FLOAT32]; - optional TensorType out_data_type = 2 [default = FLOAT32]; -} - -message SquareOptions { - // None -} - -message MaximumMinimumOptions { - //None -} - -message GreaterEqualOptions { - // None -} - -message SelectOptions { - // None -} - -message SelectV2Options { - // None -} - -message SplitOptions { - optional int32 num_splits = 1; -} - -message SplitVOptions { - optional int32 num_splits = 1; -} - -message SquaredDifferenceOptions { - // None -} - -message FillOptions { - // None -} - -message GreaterOptions { - // None -} - -message L2NormOptions { - optional Activation activation = 1 [default = NONE]; -} - -message LessOptions { - // None -} - -message LessEqualOptions { - // None -} - -message LocalResponseNormalizationOptions { - optional int32 radius = 1 [default = 5]; - optional float bias = 2 [default = 1.0]; - optional float alpha = 3 [default = 1.0]; - optional float beta = 4 [default = 0.5]; -} - -message MatMulOptions { - optional bool transpose_a = 1 [default = false]; - optional bool transpose_b = 2 [default = false]; -} - -message SqueezeOptions { - repeated int32 squeeze_dim = 1; -} - -message OneHotOptions { - optional int32 axis = 1 [default = -1]; -} - -message TopKV2Options { - // None -} - -message LogSoftmaxOptions { - // None -} - -message ZerosLikeOptions { - // None -} - -message GatherNdOptions { - // None -} - -message NonMaxSuppressionV4Options { - // None -} - -message NonMaxSuppressionV5Options { - // None -} - -message NotEqualOptions { - // None -} - -message PowOptions { - // None -} - -message LeakyReluOptions { - optional float alpha = 1 [default = 0.2]; -} - -message ResizeNearestNeighborOptions { - optional bool align_corners = 1 [default = false]; -} - -message ResizeBilinearOptions { - optional bool align_corners = 1 [default = false]; - optional bool half_pixel_centers = 2 [default = false]; -} - -message DepthToSpaceOptions { - optional int32 block_size = 1; -} - -message TransposeConvOptions { - optional Padding padding = 1 [default = VALID]; - optional int32 stride_w = 2 [default = 1]; - optional int32 stride_h = 3 [default = 1]; -} - -message ReverseSequenceOptions { - optional int32 seq_dim = 1 [default = 0]; - optional int32 batch_dim = 2 [default = 0]; -} - -message RankOptions { - // NONE -} - -message SegmentSumOptions { - // NONE -} - -message UnidirectionalSequenceLSTMOptions { - optional Activation activation = 1 [default = NONE]; - optional float cell_clip = 2 [default = 0.0]; - optional float proj_clip = 3 [default = 0.0]; - optional bool time_major = 4 [default = false]; - optional bool asymmetric_quantize_inputs = 5 [default = false]; -} - -message UniqueOptions { - optional TensorType idx_out_type = 1 [default = INT32]; -} - -message WhereOptions { - // None -} - -message SparseToDenseOptions { - optional bool validate_indices = 1 [default = true]; -} - -message ReverseV2Options { - // None -} - -message MatrixDiagOptions { - // NONE -} - -message MatrixSetDiagOptions { - // NONE -} - -message DequantizeOptions { - // NONE -} - message Operation { optional string type = 1; repeated string input = 2; repeated string output = 3; - optional int32 version = 4 [default = 1]; optional Conv2DOptions conv2d_options = 100; optional Pool2DOptions averagepool2d_options = 101; @@ -509,118 +106,6 @@ message Operation { optional SubOptions sub_options = 106; optional DivOptions div_options = 107; optional FullyConnectedOptions fullyconnected_options = 108; - optional AddOptions add_options = 109; - optional ArgMaxOptions argmax_options = 110; - optional PadOptions pad_options = 111; - optional SoftmaxOptions softmax_options = 112; - optional MulOptions mul_options = 113; - optional ReducerOptions mean_options = 114; - optional TransposeOptions transpose_options = 115; - optional PackOptions pack_options = 116; - optional LogicalOrOptions logical_or_options = 117; - optional LogicalNotOptions logical_not_options = 118; - optional LogicalAndOptions logical_and_options = 119; - optional AbsOptions abs_options = 120; - optional CosOptions cos_options = 121; - optional EqualOptions equal_options = 122; - optional ShapeOptions shape_options = 123; - optional FloorDivOptions floordiv_options = 124; - optional BatchToSpaceNDOptions batch_to_space_options = 125; - optional ExpOptions exp_options = 126; - optional UnpackOptions unpack_options = 127; - optional GatherOptions gather_options = 128; - optional BatchMatMulOptions batch_matmul_options = 129; - optional TileOptions tile_options = 130; - optional IfOptions if_options = 131; - optional WhileOptions while_options = 132; - optional SpaceToBatchNDOptions space_to_batch_nd_options = 133; - optional CastOptions cast_options = 134; - optional GreaterEqualOptions greaterequal_options = 135; - optional MaximumMinimumOptions maximum_options = 136; - optional StridedSliceOptions strided_slice_options = 137; - optional SquaredDifferenceOptions squared_difference_options = 138; - optional FillOptions fill_options = 139; - optional SelectOptions select_options = 140; - optional ReducerOptions reduce_prod_options = 141; - optional SplitOptions split_options = 142; - optional SplitVOptions split_v_options = 143; - optional ReducerOptions sum_options = 144; - optional GreaterOptions greater_options = 145; - optional SqueezeOptions squeeze_options = 146; - optional FloorModOptions floormod_options = 147; - optional OneHotOptions onehot_options = 148; - optional LessOptions less_options = 149; - optional ReducerOptions reduce_max_options = 150; - optional MaximumMinimumOptions minimum_options = 151; - optional ReducerOptions reduce_any_options = 152; - optional ZerosLikeOptions zeros_like_options = 153; - // ConcatEmbeddingsOptions 154 - // LSHProjectionOptions 155 - // SVDFOptions 156 - // RNNOptions 157 - optional L2NormOptions l2norm_options = 158; - optional LocalResponseNormalizationOptions local_response_normalization_options = 159; - // LSTMOptions 160 - optional ResizeBilinearOptions resize_bilinear_options = 161; - // CallOptions 162 - // SkipGramOptions 163 - optional SpaceToDepthOptions space_to_depth_options = 164; - // EmbeddingLookupSparseOptions 165 - // SequenceRNNOptions 166 - optional TopKV2Options topk_v2_options = 167; - optional LogSoftmaxOptions log_softmax_options = 168; - optional DequantizeOptions dequantize_options = 169; - optional NegOptions neg_options = 170; - optional PadV2Options padv2_options = 171; - optional LessEqualOptions lessequal_options = 172; - optional SliceOptions slice_options = 173; - optional TransposeConvOptions transpose_conv_options = 174; - optional SparseToDenseOptions sparse_to_dense_options = 175; - optional PowOptions pow_options = 176; - optional ArgMinOptions argmin_options = 177; - // FakeQuantOptions 178 - // BidirectionalSequenceLSTMOptions 179 - // BidirectionalSequenceRNNOptions 180 - optional UnidirectionalSequenceLSTMOptions unidirectional_sequence_lstm_options = 181; - optional RangeOptions range_options = 182; - optional ResizeNearestNeighborOptions resize_nearest_neighbor_options = 183; - optional LeakyReluOptions leaky_relu_options = 184; - optional MirrorPadOptions mirrorpad_options = 185; - optional UniqueOptions unique_options = 186; - optional ReverseV2Options reversev2_options = 187; - // AddNOptions 188 - optional GatherNdOptions gather_nd_options = 189; - optional WhereOptions where_options = 190; - optional RankOptions rank_options = 191; - optional ReverseSequenceOptions reverse_sequence_options = 192; - optional MatrixDiagOptions matrix_diag_options = 193; - // QuantizeOptions 194 - optional MatrixSetDiagOptions matrix_set_diag_options = 195; - // HardSwishOptions 196 - optional DepthToSpaceOptions depth_to_space_options = 197; - optional NonMaxSuppressionV4Options non_max_suppression_v4_options = 198; - optional NonMaxSuppressionV5Options non_max_suppression_v5_options = 199; - optional ScatterNdOptions scatter_nd_options = 200; - optional NotEqualOptions notequal_options = 201; - optional ExpandDimsOptions expand_dims_options = 202; - optional Pool2DOptions l2pool2d_options = 203; - optional ReducerOptions all_options = 204; - optional ReducerOptions reduce_min_options = 205; - optional SegmentSumOptions segment_sum_options = 206; - optional AddNOptions add_n_options = 207; - optional MatMulOptions matmul_options = 208; - - // NOTE if there are more than two options with same type of Options - // use the number not listed in the above reserve list -} - -// For additional subgraphs -message Graph { - repeated Operand operand = 1; - repeated Operation operation = 2; - repeated string input = 3; - repeated string output = 4; - optional string name = 5; } message ModelRecipe { @@ -628,7 +113,4 @@ message ModelRecipe { repeated Operation operation = 2; repeated string input = 3; repeated string output = 4; - optional string name = 5; - optional uint32 version = 6 [default = 1]; - repeated Graph graph = 7; } diff --git a/compiler/tflchef/requires.cmake b/compiler/tflchef/requires.cmake index 4c02174b5..5f055bbf8 100644 --- a/compiler/tflchef/requires.cmake +++ b/compiler/tflchef/requires.cmake @@ -1,9 +1,2 @@ -require("arser") require("nnkit") require("cwrap") -require("mio-tflite") -require("safemain") -require("hermes") -require("hermes-std") -require("foder") -require("souschef") diff --git a/compiler/tflchef/tests/CMakeLists.txt b/compiler/tflchef/tests/CMakeLists.txt index 5c4dff012..e55f4c72c 100644 --- a/compiler/tflchef/tests/CMakeLists.txt +++ b/compiler/tflchef/tests/CMakeLists.txt @@ -6,62 +6,34 @@ if(NOT TARGET nnkit_tflite_backend) return() endif(NOT TARGET nnkit_tflite_backend) -nncc_find_resource(TensorFlowLiteRecipes) -set(TENSORFLOWLITERECIPES_DIR "${TensorFlowLiteRecipes_DIR}") - -file(GLOB RECIPES RELATIVE ${TENSORFLOWLITERECIPES_DIR} "${TENSORFLOWLITERECIPES_DIR}/*/test.recipe") - -foreach(RECIPE IN ITEMS ${RECIPES}) - get_filename_component(RECIPE_PREFIX ${RECIPE} DIRECTORY) - - set(RECIPE_SOURCE_FILE "${RECIPE_PREFIX}.recipe") - set(RECIPE_OUTPUT_FILE "${RECIPE_PREFIX}.tflite") - - # Copy .recipe - add_custom_command(OUTPUT ${RECIPE_SOURCE_FILE} - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${TENSORFLOWLITERECIPES_DIR}/${RECIPE}" ${RECIPE_SOURCE_FILE} - DEPENDS "${TENSORFLOWLITERECIPES_DIR}/${RECIPE}" - COMMENT "Generating ${RECIPE_SOURCE_FILE}") - - # Generate .tflite - add_custom_command(OUTPUT ${RECIPE_OUTPUT_FILE} - COMMAND tflchef-file ${RECIPE_SOURCE_FILE} ${RECIPE_OUTPUT_FILE} - DEPENDS tflchef-file ${RECIPE_SOURCE_FILE} - COMMENT "Generating ${RECIPE_OUTPUT_FILE}") - - list(APPEND TESTS ${RECIPE_PREFIX}) - list(APPEND TESTFILES ${RECIPE_OUTPUT_FILE}) -endforeach(RECIPE) - -# Add local files file(GLOB RECIPES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/test.recipe") foreach(RECIPE IN ITEMS ${RECIPES}) get_filename_component(RECIPE_PREFIX ${RECIPE} DIRECTORY) set(RECIPE_SOURCE_FILE "${RECIPE_PREFIX}.recipe") + set(RECIPE_SOURCE_TARGET tflchef_${RECIPE_PREFIX}_recipe) + set(RECIPE_OUTPUT_FILE "${RECIPE_PREFIX}.tflite") + set(RECIPE_OUTPUT_TARGET tflchef_${RECIPE_PREFIX}_tflite) # Copy .recipe - add_custom_command(OUTPUT ${RECIPE_SOURCE_FILE} - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${CMAKE_CURRENT_SOURCE_DIR}/${RECIPE}" ${RECIPE_SOURCE_FILE} - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${RECIPE}" - COMMENT "Generating ${RECIPE_SOURCE_FILE}") + add_custom_target(${RECIPE_SOURCE_TARGET} + ALL ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${RECIPE}" + "${CMAKE_CURRENT_BINARY_DIR}/${RECIPE_SOURCE_FILE}" + COMMENT "Generate ${RECIPE_PREFIX}.recipe") # Generate .tflite - add_custom_command(OUTPUT ${RECIPE_OUTPUT_FILE} - COMMAND tflchef-file ${RECIPE_SOURCE_FILE} ${RECIPE_OUTPUT_FILE} - DEPENDS tflchef-file ${RECIPE_SOURCE_FILE} - COMMENT "Generating ${RECIPE_OUTPUT_FILE}") + add_custom_target(${RECIPE_OUTPUT_TARGET} + ALL $<TARGET_FILE:tflchef-file> ${RECIPE_SOURCE_FILE} ${RECIPE_OUTPUT_FILE} + DEPENDS ${RECIPE_SOURCE_TARGET} + COMMENT "Generate ${RECIPE_PREFIX}.tflite") list(APPEND TESTS ${RECIPE_PREFIX}) - list(APPEND TESTFILES ${RECIPE_OUTPUT_FILE}) endforeach(RECIPE) # Test tflchef-reverse -file(GLOB GEN_TFLITEFILES RELATIVE ${TENSORFLOWLITERECIPES_DIR} "${TENSORFLOWLITERECIPES_DIR}/*/test.reverse") +file(GLOB GEN_TFLITEFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/test.reverse") # Note: While in development, tflchef-reverse may not handle the operator. # To separate this linkage scan empty test.reverse for test targets for tflchef-reverse. @@ -71,59 +43,34 @@ foreach(TFLITEFILE IN ITEMS ${GEN_TFLITEFILES}) # file from above tflchef-file block # use tflite file as input of tflchef-reverse generated from tflchef-file set(RECIPE_OUTPUT_FILE "${TFLITE_PREFIX}.tflite") + set(RECIPE_OUTPUT_TARGET tflchef_${TFLITE_PREFIX}_tflite) + set(RECIPE_GEN_OUTPUT_FILE "${TFLITE_PREFIX}.gen.recipe") - set(RECIPE_GEN_OUTPUT_FILE2 "${TFLITE_PREFIX}.gen.tflite") + set(RECIPE_GEN_OUTPUT_TARGET tflchef_${TFLITE_PREFIX}_gen_recipe) # Generate .gen.recipe from generated .tflite - add_custom_command(OUTPUT ${RECIPE_GEN_OUTPUT_FILE} - COMMAND tflchef-reverse ${RECIPE_OUTPUT_FILE} ${RECIPE_GEN_OUTPUT_FILE} - DEPENDS tflchef-reverse ${RECIPE_OUTPUT_FILE} - COMMENT "Generating ${RECIPE_GEN_OUTPUT_FILE}") + add_custom_target(${RECIPE_GEN_OUTPUT_TARGET} + ALL $<TARGET_FILE:tflchef-reverse> ${RECIPE_OUTPUT_FILE} ${RECIPE_GEN_OUTPUT_FILE} + DEPENDS ${RECIPE_OUTPUT_TARGET} + COMMENT "Generate ${TFLITE_PREFIX}.gen.recipe") # now we are going to generate .gen.tflite from .gen.recipe # to check generated .gen.recipe file is correct by using it. # as weight values may be different, binary comparision is not acceptable. - add_custom_command(OUTPUT ${RECIPE_GEN_OUTPUT_FILE2} - COMMAND tflchef-file ${RECIPE_GEN_OUTPUT_FILE} ${RECIPE_GEN_OUTPUT_FILE2} - DEPENDS tflchef-file ${RECIPE_GEN_OUTPUT_FILE} - COMMENT "Generating ${RECIPE_GEN_OUTPUT_FILE2}") - - list(APPEND TESTS ${TFLITE_PREFIX}.gen) - list(APPEND TESTFILES ${RECIPE_GEN_OUTPUT_FILE2}) -endforeach(TFLITEFILE) - -# Test local tflchef-reverse -file(GLOB GEN_TFLITEFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/test.reverse") - -foreach(TFLITEFILE IN ITEMS ${GEN_TFLITEFILES}) - get_filename_component(TFLITE_PREFIX ${TFLITEFILE} DIRECTORY) - - set(RECIPE_OUTPUT_FILE "${TFLITE_PREFIX}.tflite") - set(RECIPE_GEN_OUTPUT_FILE "${TFLITE_PREFIX}.gen.recipe") set(RECIPE_GEN_OUTPUT_FILE2 "${TFLITE_PREFIX}.gen.tflite") + set(RECIPE_GEN_OUTPUT_TARGET2 tflchef_${TFLITE_PREFIX}_gen_tflite) - # Generate .gen.recipe from generated .tflite - add_custom_command(OUTPUT ${RECIPE_GEN_OUTPUT_FILE} - COMMAND tflchef-reverse ${RECIPE_OUTPUT_FILE} ${RECIPE_GEN_OUTPUT_FILE} - DEPENDS tflchef-reverse ${RECIPE_OUTPUT_FILE} - COMMENT "Generating ${RECIPE_GEN_OUTPUT_FILE}") - - add_custom_command(OUTPUT ${RECIPE_GEN_OUTPUT_FILE2} - COMMAND tflchef-file ${RECIPE_GEN_OUTPUT_FILE} ${RECIPE_GEN_OUTPUT_FILE2} - DEPENDS tflchef-file ${RECIPE_GEN_OUTPUT_FILE} - COMMENT "Generating ${RECIPE_GEN_OUTPUT_FILE2}") + add_custom_target(${RECIPE_GEN_OUTPUT_TARGET2} + ALL $<TARGET_FILE:tflchef-file> ${RECIPE_GEN_OUTPUT_FILE} ${RECIPE_GEN_OUTPUT_FILE2} + DEPENDS ${RECIPE_GEN_OUTPUT_TARGET} + COMMENT "Generate ${TFLITE_PREFIX}.gen.tflite") list(APPEND TESTS ${TFLITE_PREFIX}.gen) - list(APPEND TESTFILES ${RECIPE_GEN_OUTPUT_FILE2}) endforeach(TFLITEFILE) -# Add a dummy target to create a target-level dependency. -# TODO Find a way to create a dependency between tflchef_test and generated testfiles. -add_custom_target(tflchef_testfiles ALL DEPENDS ${TESTFILES}) - -# Using mio_tflite_validate for temporary as it only calls flatbuffer validate -# TODO do testing with running the model with runtime/interpreter add_test(NAME tflchef_test - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/runvalidate.sh" - $<TARGET_FILE:mio_tflite_validate> + COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/runall.sh" + $<TARGET_FILE:nnkit-run> + $<TARGET_FILE:nnkit_tflite_backend> + "${CMAKE_CURRENT_BINARY_DIR}" ${TESTS}) diff --git a/compiler/tflchef/tests/averagepool2d/test.recipe b/compiler/tflchef/tests/averagepool2d/test.recipe new file mode 100644 index 000000000..746c34334 --- /dev/null +++ b/compiler/tflchef/tests/averagepool2d/test.recipe @@ -0,0 +1,24 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 1 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 1 } +} +operation { + type: "AveragePool2D" + averagepool2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + filter_width: 2 + filter_height: 2 + } + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/no_shape/test.reverse b/compiler/tflchef/tests/averagepool2d/test.reverse index e69de29bb..e69de29bb 100644 --- a/compiler/tflchef/tests/no_shape/test.reverse +++ b/compiler/tflchef/tests/averagepool2d/test.reverse diff --git a/compiler/tflchef/tests/concatenation/test.recipe b/compiler/tflchef/tests/concatenation/test.recipe new file mode 100644 index 000000000..35641bd07 --- /dev/null +++ b/compiler/tflchef/tests/concatenation/test.recipe @@ -0,0 +1,28 @@ +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 1 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 2 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operation { + type: "Concatenation" + concatenation_options { + axis: 3 + activation: NONE + } + input: "ifm1" + input: "ifm2" + output: "ofm" +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/tflchef/tests/concatenation/test.reverse b/compiler/tflchef/tests/concatenation/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/concatenation/test.reverse diff --git a/compiler/tflchef/tests/conv2d/test.recipe b/compiler/tflchef/tests/conv2d/test.recipe new file mode 100644 index 000000000..9cf8a0f69 --- /dev/null +++ b/compiler/tflchef/tests/conv2d/test.recipe @@ -0,0 +1,44 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/conv2d/test.reverse b/compiler/tflchef/tests/conv2d/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/conv2d/test.reverse diff --git a/compiler/tflchef/tests/depthwiseconv2d/test.recipe b/compiler/tflchef/tests/depthwiseconv2d/test.recipe new file mode 100644 index 000000000..17a3b06c7 --- /dev/null +++ b/compiler/tflchef/tests/depthwiseconv2d/test.recipe @@ -0,0 +1,41 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 64 dim: 64 dim: 8 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 8 } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 8 } + filler { + tag: "constant" + arg: "1.1" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 64 dim: 64 dim: 8 } +} +operation { + type: "DepthwiseConv2D" + depthwiseconv2d_options { + padding: SAME + stride_w: 1 + stride_h: 1 + depth_multiplier: 1 + activation : RELU6 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +input: "ker" +output: "ofm" diff --git a/compiler/tflchef/tests/depthwiseconv2d/test.reverse b/compiler/tflchef/tests/depthwiseconv2d/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/depthwiseconv2d/test.reverse diff --git a/compiler/tflchef/tests/div/test.recipe b/compiler/tflchef/tests/div/test.recipe new file mode 100644 index 000000000..4fb76d467 --- /dev/null +++ b/compiler/tflchef/tests/div/test.recipe @@ -0,0 +1,27 @@ +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 4 dim: 4 dim: 3 } +} +operation { + type: "Div" + input: "ifm1" + input: "ifm2" + output: "ofm" + div_options { + activation: NONE + } +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/tflchef/tests/div/test.reverse b/compiler/tflchef/tests/div/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/div/test.reverse diff --git a/compiler/tflchef/tests/fullyconnected/test.recipe b/compiler/tflchef/tests/fullyconnected/test.recipe new file mode 100644 index 000000000..dca4c09f0 --- /dev/null +++ b/compiler/tflchef/tests/fullyconnected/test.recipe @@ -0,0 +1,34 @@ +operand { + name: "in" + type: FLOAT32 + shape { dim: 1 dim: 64 } +} +operand { + name: "weight" + type: FLOAT32 + shape { dim: 8 dim: 64 } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 8 } +} +operand { + name: "out" + type: FLOAT32 + shape { dim: 1 dim: 8 } +} +operation { + type: "FullyConnected" + fullyconnected_options { + activation: NONE + } + input: "in" + input: "weight" + input: "bias" + output: "out" +} +input: "in" +input: "weight" +input: "bias" +output: "out" diff --git a/compiler/tflchef/tests/fullyconnected/test.reverse b/compiler/tflchef/tests/fullyconnected/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/fullyconnected/test.reverse diff --git a/compiler/tflchef/tests/fullyconnected2/test.recipe b/compiler/tflchef/tests/fullyconnected2/test.recipe new file mode 100644 index 000000000..e404f759f --- /dev/null +++ b/compiler/tflchef/tests/fullyconnected2/test.recipe @@ -0,0 +1,34 @@ +operand { + name: "in" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 4 } +} +operand { + name: "weight" + type: FLOAT32 + shape { dim: 2 dim: 4 } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 2 } +} +operand { + name: "out" + type: FLOAT32 + shape { dim: 1 dim: 2 } +} +operation { + type: "FullyConnected" + fullyconnected_options { + activation: NONE + } + input: "in" + input: "weight" + input: "bias" + output: "out" +} +input: "in" +input: "weight" +input: "bias" +output: "out" diff --git a/compiler/tflchef/tests/fullyconnected2/test.reverse b/compiler/tflchef/tests/fullyconnected2/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/fullyconnected2/test.reverse diff --git a/compiler/tflchef/tests/maxpool2d/test.recipe b/compiler/tflchef/tests/maxpool2d/test.recipe new file mode 100644 index 000000000..718630f08 --- /dev/null +++ b/compiler/tflchef/tests/maxpool2d/test.recipe @@ -0,0 +1,24 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 1 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 1 } +} +operation { + type: "MaxPool2D" + maxpool2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + filter_width: 2 + filter_height: 2 + } + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/maxpool2d/test.reverse b/compiler/tflchef/tests/maxpool2d/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/maxpool2d/test.reverse diff --git a/compiler/tflchef/tests/multisubgraph/test.recipe b/compiler/tflchef/tests/multisubgraph/test.recipe deleted file mode 100644 index b55af1337..000000000 --- a/compiler/tflchef/tests/multisubgraph/test.recipe +++ /dev/null @@ -1,72 +0,0 @@ -version: 1 - -graph { - operand { - name: "ifm" - type: FLOAT32 - shape { dim: 1 dim: 3 dim: 3 dim: 2 } - } - operand { - name: "ofm" - type: FLOAT32 - shape { dim: 1 dim: 3 dim: 3 dim: 2 } - } - operation { - type: "ReLU" - input: "ifm" - output: "ofm" - } - input: "ifm" - output: "ofm" - name: "Sub_01" -} - -graph { - operand { - name: "ifm" - type: FLOAT32 - shape { dim: 1 dim: 3 dim: 3 dim: 2 } - } - operand { - name: "ofm" - type: FLOAT32 - shape { dim: 1 dim: 3 dim: 3 dim: 2 } - } - operation { - type: "ReLU6" - input: "ifm" - output: "ofm" - } - input: "ifm" - output: "ofm" - name: "Sub_01" -} - -operand { - name: "ifm1" - type: FLOAT32 - shape { dim: 1 dim: 3 dim: 3 dim: 2 } -} -operand { - name: "ifm2" - type: FLOAT32 - shape { dim: 1 dim: 3 dim: 3 dim: 2 } -} -operand { - name: "ofm" - type: FLOAT32 - shape { dim: 1 dim: 3 dim: 3 dim: 2 } -} -operation { - type: "Add" - input: "ifm1" - input: "ifm2" - output: "ofm" - add_options { - activation: NONE - } -} -input: "ifm1" -input: "ifm2" -output: "ofm" -name: "Main" diff --git a/compiler/tflchef/tests/no_shape/test.recipe b/compiler/tflchef/tests/no_shape/test.recipe deleted file mode 100644 index 38efef96a..000000000 --- a/compiler/tflchef/tests/no_shape/test.recipe +++ /dev/null @@ -1,43 +0,0 @@ -operand { - name: "indices" - type: INT32 - shape { dim: 4 } -} -operand { - name: "depth" - type: INT32 - # shape is intentionally omitted here - filler { tag: "explicit" arg: "1" } -} -operand { - name: "on_value" - type: INT32 - # shape is intentionally omitted here - filler { tag: "explicit" arg: "1" } -} -operand { - name: "off_value" - type: INT32 - # shape is intentionally omitted here - filler { tag: "explicit" arg: "0" } -} -operand { - name: "ofm" - type: INT32 - shape { dim: 4 dim: 1 } -} -operation { - type: "OneHot" - onehot_options { - axis: -1 - } - input: "indices" - input: "depth" - input: "on_value" - input: "off_value" - output: "ofm" -} -input: "indices" -input: "on_value" -input: "off_value" -output: "ofm" diff --git a/compiler/tflchef/tests/quantization/test.recipe b/compiler/tflchef/tests/quantization/test.recipe new file mode 100644 index 000000000..be5d222a2 --- /dev/null +++ b/compiler/tflchef/tests/quantization/test.recipe @@ -0,0 +1,46 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } + quant { min: 0 max: 128 scale: 2 zero_point: 2 } +} +operand { + name: "ker" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 1 } + quant { min: 0 max: 80 scale: 1.5 zero_point: 3 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + } + input: "ifm" + input: "ker" + input: "bias" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/quantization/test.reverse b/compiler/tflchef/tests/quantization/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/quantization/test.reverse diff --git a/compiler/tflchef/tests/relu/test.recipe b/compiler/tflchef/tests/relu/test.recipe new file mode 100644 index 000000000..8eaa3602f --- /dev/null +++ b/compiler/tflchef/tests/relu/test.recipe @@ -0,0 +1,17 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operation { + type: "ReLU" + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/relu/test.reverse b/compiler/tflchef/tests/relu/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/relu/test.reverse diff --git a/compiler/tflchef/tests/relu6/test.recipe b/compiler/tflchef/tests/relu6/test.recipe new file mode 100644 index 000000000..226593593 --- /dev/null +++ b/compiler/tflchef/tests/relu6/test.recipe @@ -0,0 +1,17 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operation { + type: "ReLU6" + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/relu6/test.reverse b/compiler/tflchef/tests/relu6/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/relu6/test.reverse diff --git a/compiler/tflchef/tests/reshape/test.recipe b/compiler/tflchef/tests/reshape/test.recipe new file mode 100644 index 000000000..cdca58980 --- /dev/null +++ b/compiler/tflchef/tests/reshape/test.recipe @@ -0,0 +1,20 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 10 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 10 } +} +operation { + type: "Reshape" + reshape_options { + new_shape: 10 + } + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/reshape/test.reverse b/compiler/tflchef/tests/reshape/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/reshape/test.reverse diff --git a/compiler/tflchef/tests/runvalidate.sh b/compiler/tflchef/tests/runvalidate.sh deleted file mode 100755 index 0dd9d16e0..000000000 --- a/compiler/tflchef/tests/runvalidate.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -if [[ $# -le 2 ]]; then - echo "USAGE: $0 [mio_tflite_validate path] [prefix 0] " - exit 255 -fi - -MIO_TFLITE_VALIDATE_PATH="$1"; shift - -echo "-- Found mio_tflite_validate: ${MIO_TFLITE_VALIDATE_PATH}" - -TESTED=() -PASSED=() -FAILED=() - -pushd "${WORKDIR}" -while [[ $# -ne 0 ]]; do - PREFIX="$1"; shift - - TESTED+=("${PREFIX}") - - PASSED_TAG="${PREFIX}.passed" - - rm -f "${PASSED_TAG}" - - cat > "${PREFIX}.log" <( - exec 2>&1 - - echo "'${MIO_TFLITE_VALIDATE_PATH}' '${PREFIX}.tflite'" - "${MIO_TFLITE_VALIDATE_PATH}" "${PREFIX}.tflite" - - if [[ $? -eq 0 ]]; then - touch "${PASSED_TAG}" - fi - ) - - if [[ -f "${PASSED_TAG}" ]]; then - PASSED+=("$PREFIX") - else - FAILED+=("$PREFIX") - fi -done -popd - -echo "SUMMARY: ${#PASSED[@]} PASS AND ${#FAILED[@]} FAIL AMONG ${#TESTED[@]} TESTS" - -if [[ ${#TESTED[@]} -ne ${#PASSED[@]} ]]; then - echo "FAILED" - for TEST in "${FAILED[@]}" - do - echo "- ${TEST}" - done - exit 255 -fi - -exit 0 diff --git a/compiler/tflchef/tests/sqrt/test.recipe b/compiler/tflchef/tests/sqrt/test.recipe new file mode 100644 index 000000000..1754f9a58 --- /dev/null +++ b/compiler/tflchef/tests/sqrt/test.recipe @@ -0,0 +1,18 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } + filler { tag: "constant" arg: "3.5" } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operation { + type: "Sqrt" + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm" diff --git a/compiler/tflchef/tests/sub/test.recipe b/compiler/tflchef/tests/sub/test.recipe new file mode 100644 index 000000000..c934bb8aa --- /dev/null +++ b/compiler/tflchef/tests/sub/test.recipe @@ -0,0 +1,27 @@ +operand { + name: "ifm1" + type: FLOAT32 + shape { dim: 1 dim: 5 dim:2 dim:3 } +} +operand { + name: "ifm2" + type: FLOAT32 + shape { dim: 1 dim: 5 dim:2 dim:3 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 5 dim:2 dim:3 } +} +operation { + type: "Sub" + sub_options { + activation: 0 + } + input: "ifm1" + input: "ifm2" + output: "ofm" +} +input: "ifm1" +input: "ifm2" +output: "ofm" diff --git a/compiler/tflchef/tests/sub/test.reverse b/compiler/tflchef/tests/sub/test.reverse new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/compiler/tflchef/tests/sub/test.reverse diff --git a/compiler/tflchef/tflite/CMakeLists.txt b/compiler/tflchef/tflite/CMakeLists.txt index 83127cb3e..477c70c4c 100644 --- a/compiler/tflchef/tflite/CMakeLists.txt +++ b/compiler/tflchef/tflite/CMakeLists.txt @@ -4,7 +4,6 @@ add_library(tflchef_tflite STATIC ${SOURCES}) target_include_directories(tflchef_tflite PUBLIC include) target_include_directories(tflchef_tflite PRIVATE src) target_link_libraries(tflchef_tflite tflchef_proto) -target_link_libraries(tflchef_tflite mio_tflite) +target_link_libraries(tflchef_tflite tflchef_flatbuffer) target_link_libraries(tflchef_tflite stdex) target_link_libraries(tflchef_tflite cwrap) -target_link_libraries(tflchef_tflite souschef) diff --git a/compiler/tflchef/log/src/LoggingContext.cpp b/compiler/tflchef/tflite/include/tflchef/RawModel.h index 0514dc38c..6979f65fd 100644 --- a/compiler/tflchef/log/src/LoggingContext.cpp +++ b/compiler/tflchef/tflite/include/tflchef/RawModel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,28 @@ * limitations under the License. */ -#include "LoggingContext.h" -#include "Log.h" +#ifndef __RAW_MODEL_H__ +#define __RAW_MODEL_H__ -#include <hermes/ConsoleReporter.h> - -#include <memory> +#include "tflite_generated.h" namespace tflchef { -hermes::Context *LoggingContext::get(void) +struct RawModel { - static hermes::Context *ctx = nullptr; + virtual ~RawModel() = default; - if (ctx == nullptr) - { - ctx = new hermes::Context; - ctx->sinks()->append(std::make_unique<hermes::ConsoleReporter>()); - ctx->config(std::make_unique<LoggerConfig>()); - } + virtual const ::tflite::Model *model(void) const = 0; +}; - return ctx; -} +/** + * @brief Load TensorFlow Lite model (as a RawModel) from a given path + * + * @note May return a nullptr + */ +std::unique_ptr<RawModel> load_tflite(const std::string &path); } // namespace tflchef + +#endif // __RAW_MODEL_H__ diff --git a/compiler/tflchef/tflite/include/tflchef/RecipeChef.h b/compiler/tflchef/tflite/include/tflchef/RecipeChef.h index 2d292c3d5..98f9f1f82 100644 --- a/compiler/tflchef/tflite/include/tflchef/RecipeChef.h +++ b/compiler/tflchef/tflite/include/tflchef/RecipeChef.h @@ -17,7 +17,7 @@ #ifndef __RECIPE_CHEF_H__ #define __RECIPE_CHEF_H__ -#include <mio/tflite/schema_generated.h> +#include <tflite_generated.h> #include <tflchef.pb.h> #include <memory> diff --git a/compiler/tflchef/tflite/src/Convert.cpp b/compiler/tflchef/tflite/src/Convert.cpp index 29276ff94..b7a93cb57 100644 --- a/compiler/tflchef/tflite/src/Convert.cpp +++ b/compiler/tflchef/tflite/src/Convert.cpp @@ -27,15 +27,12 @@ tflchef::TensorType as_tflchef_type(const tflite::TensorType type) return tflchef::FLOAT32; case tflite::TensorType_INT32: return tflchef::INT32; - case tflite::TensorType_INT64: - return tflchef::INT64; - case tflite::TensorType_UINT8: - return tflchef::UINT8; - case tflite::TensorType_BOOL: - return tflchef::BOOL; // TODO handle other types // TensorType_FLOAT16 + // TensorType_UINT8 + // TensorType_INT64 // TensorType_STRING + // TensorType_BOOL // TensorType_INT16 // TensorType_COMPLEX64 default: @@ -51,14 +48,12 @@ tflchef::Activation as_tflchef_activation(const tflite::ActivationFunctionType t return tflchef::NONE; case tflite::ActivationFunctionType_RELU: return tflchef::RELU; - case tflite::ActivationFunctionType_RELU_N1_TO_1: - return tflchef::RELU_N1_TO_1; case tflite::ActivationFunctionType_RELU6: return tflchef::RELU6; - case tflite::ActivationFunctionType_TANH: - return tflchef::TANH; - case tflite::ActivationFunctionType_SIGN_BIT: - return tflchef::SIGN_BIT; + // TODO handle other types + // ActivationFunctionType_RELU_N1_TO_1 + // ActivationFunctionType_TANH + // ActivationFunctionType_SIGN_BIT default: throw std::runtime_error{"unsupported activation type"}; } @@ -77,47 +72,4 @@ tflchef::Padding as_tflchef_padding(const tflite::Padding padding) } } -tflchef::MirrorPadMode as_tflchef_mirrorpadmode(const tflite::MirrorPadMode mode) -{ - switch (mode) - { - case tflite::MirrorPadMode_REFLECT: - return tflchef::REFLECT; - case tflite::MirrorPadMode_SYMMETRIC: - return tflchef::SYMMETRIC; - default: - throw std::runtime_error{"Unknown mirrorpad mode"}; - } -} - -tflchef::DimensionType as_tflchef_sparse_dim_type(const tflite::DimensionType type) -{ - switch (type) - { - case tflite::DimensionType_DENSE: - return tflchef::DimensionType::DENSE; - case tflite::DimensionType_SPARSE_CSR: - return tflchef::DimensionType::SPARSE_CSR; - default: - throw std::runtime_error("unsupported sparse dimension type"); - } -} - -tflchef::SparseIndexVecType as_tflchef_sparse_idx_vec_type(const tflite::SparseIndexVector type) -{ - switch (type) - { - case tflite::SparseIndexVector_NONE: - return tflchef::SparseIndexVecType::SparseIdxVecType_NONE; - case tflite::SparseIndexVector_Int32Vector: - return tflchef::SparseIndexVecType::INT32VEC; - case tflite::SparseIndexVector_Uint16Vector: - return tflchef::SparseIndexVecType::UINT16VEC; - case tflite::SparseIndexVector_Uint8Vector: - return tflchef::SparseIndexVecType::UINT8VEC; - default: - throw std::runtime_error("unsupported sparse index vector type"); - } -} - } // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Convert.h b/compiler/tflchef/tflite/src/Convert.h index cf0c61550..4973da111 100644 --- a/compiler/tflchef/tflite/src/Convert.h +++ b/compiler/tflchef/tflite/src/Convert.h @@ -17,7 +17,7 @@ #ifndef __CONVERT_H__ #define __CONVERT_H__ -#include <mio/tflite/schema_generated.h> +#include <tflite_generated.h> #include <tflchef.pb.h> @@ -27,22 +27,6 @@ namespace tflchef tflchef::TensorType as_tflchef_type(const tflite::TensorType type); tflchef::Activation as_tflchef_activation(const tflite::ActivationFunctionType type); tflchef::Padding as_tflchef_padding(const tflite::Padding padding); -tflchef::MirrorPadMode as_tflchef_mirrorpadmode(const tflite::MirrorPadMode mode); -tflchef::DimensionType as_tflchef_sparse_dim_type(const tflite::DimensionType type); -tflchef::SparseIndexVecType as_tflchef_sparse_idx_vec_type(const tflite::SparseIndexVector type); - -/** - * @brief extract buffer data to std::vector<DT> - */ -template <typename DT> std::vector<DT> extract_buffer(const tflite::Buffer *buffer) -{ - assert(buffer->data() != nullptr); - auto buffer_length = buffer->data()->size(); - auto num_elements = buffer_length / sizeof(DT); - std::vector<DT> result(num_elements); - std::memcpy(result.data(), buffer->data()->data(), buffer_length); - return result; -} template <typename T> std::vector<T> as_index_vector(const flatbuffers::Vector<T> *flat_array) { diff --git a/compiler/tflchef/tflite/src/FillerHelper.cpp b/compiler/tflchef/tflite/src/FillerHelper.cpp deleted file mode 100644 index cf96d2e8c..000000000 --- a/compiler/tflchef/tflite/src/FillerHelper.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "FillerHelper.h" - -#include "Convert.h" - -namespace tflchef -{ - -void fill_tensor_to_import(int32_t idx, TFliteImport *import) -{ - const tflite::Tensor *tensor = import->tensors()->Get(idx); - if (tensor != nullptr) - { - if (tensor->type() == tflite::TensorType::TensorType_INT32) - { - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - if (buffer && buffer->data()) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(idx, vec); - } - } - else if (tensor->type() == tflite::TensorType::TensorType_FLOAT32) - { - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - if (buffer && buffer->data()) - { - auto vec = extract_buffer<float>(buffer); - import->set_tensor_filler(idx, vec); - } - } - } -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Abs.cpp b/compiler/tflchef/tflite/src/Op/Abs.cpp deleted file mode 100644 index 7d769e344..000000000 --- a/compiler/tflchef/tflite/src/Op/Abs.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Abs.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpAbs::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpAbs::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Abs"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Abs.h b/compiler/tflchef/tflite/src/Op/Abs.h deleted file mode 100644 index d99b0d593..000000000 --- a/compiler/tflchef/tflite/src/Op/Abs.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ABS_H__ -#define __TFLITE_OP_ABS_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for abs - */ -class TFliteOpAbs : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ABS_H__ diff --git a/compiler/tflchef/tflite/src/Op/Add.cpp b/compiler/tflchef/tflite/src/Op/Add.cpp deleted file mode 100644 index 3e880a63b..000000000 --- a/compiler/tflchef/tflite/src/Op/Add.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Add.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpAdd::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Add may have constant input - - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - assert(inputs.size() == 2); - - fill_tensor_to_import(inputs[0], import); - fill_tensor_to_import(inputs[1], import); -} - -tflchef::Operation *TFliteOpAdd::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_AddOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Add"); - - auto op_options = operation->mutable_add_options(); - - op_options->set_activation(as_tflchef_activation(op_params->fused_activation_function())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Add.h b/compiler/tflchef/tflite/src/Op/Add.h deleted file mode 100644 index 49d945f8b..000000000 --- a/compiler/tflchef/tflite/src/Op/Add.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ADD_H__ -#define __TFLITE_OP_ADD_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for add - */ -class TFliteOpAdd : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ADD_H__ diff --git a/compiler/tflchef/tflite/src/Op/AddN.cpp b/compiler/tflchef/tflite/src/Op/AddN.cpp deleted file mode 100644 index aeb3803ab..000000000 --- a/compiler/tflchef/tflite/src/Op/AddN.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "AddN.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpAddN::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // AddN may have constant input - - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - - for (uint32_t idx = 0; idx < inputs.size(); ++idx) - fill_tensor_to_import(inputs[idx], import); -} - -tflchef::Operation *TFliteOpAddN::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("AddN"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/AddN.h b/compiler/tflchef/tflite/src/Op/AddN.h deleted file mode 100644 index 4387aa06a..000000000 --- a/compiler/tflchef/tflite/src/Op/AddN.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ADD_N_H__ -#define __TFLITE_OP_ADD_N_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for AddN - */ -class TFliteOpAddN : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ADD_N_H__ diff --git a/compiler/tflchef/tflite/src/Op/ArgMax.cpp b/compiler/tflchef/tflite/src/Op/ArgMax.cpp deleted file mode 100644 index f4d1c5e66..000000000 --- a/compiler/tflchef/tflite/src/Op/ArgMax.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ArgMax.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpArgMax::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input, argmax/dim - const auto &inputs = *op->inputs(); - - const tflite::Tensor *dim_tensor = import->tensors()->Get(inputs[1]); - assert(dim_tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(dim_tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpArgMax::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ArgMaxOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("ArgMax"); - - auto op_options = operation->mutable_argmax_options(); - - op_options->set_output_type(as_tflchef_type(op_params->output_type())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ArgMax.h b/compiler/tflchef/tflite/src/Op/ArgMax.h deleted file mode 100644 index 30068ecf2..000000000 --- a/compiler/tflchef/tflite/src/Op/ArgMax.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ARGMAX_H__ -#define __TFLITE_OP_ARGMAX_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ArgMax - */ -class TFliteOpArgMax : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ARGMAX_H__ diff --git a/compiler/tflchef/tflite/src/Op/ArgMin.cpp b/compiler/tflchef/tflite/src/Op/ArgMin.cpp deleted file mode 100644 index faab0b830..000000000 --- a/compiler/tflchef/tflite/src/Op/ArgMin.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ArgMin.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpArgMin::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input, argmin/dim - const auto &inputs = *op->inputs(); - - const tflite::Tensor *dim_tensor = import->tensors()->Get(inputs[1]); - assert(dim_tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(dim_tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpArgMin::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ArgMinOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("ArgMin"); - - auto op_options = operation->mutable_argmin_options(); - - op_options->set_output_type(as_tflchef_type(op_params->output_type())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ArgMin.h b/compiler/tflchef/tflite/src/Op/ArgMin.h deleted file mode 100644 index 83c643c1a..000000000 --- a/compiler/tflchef/tflite/src/Op/ArgMin.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ARGMIN_H__ -#define __TFLITE_OP_ARGMIN_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ArgMin - */ -class TFliteOpArgMin : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ARGMIN_H__ diff --git a/compiler/tflchef/tflite/src/Op/BatchMatMul.cpp b/compiler/tflchef/tflite/src/Op/BatchMatMul.cpp deleted file mode 100644 index 598e58c94..000000000 --- a/compiler/tflchef/tflite/src/Op/BatchMatMul.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "BatchMatMul.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpBatchMatMul::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpBatchMatMul::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("BatchMatMul"); - - auto op_options = operation->mutable_batch_matmul_options(); - - auto op_params = op->builtin_options_as_BatchMatMulOptions(); - assert(op_params != nullptr); - - op_options->set_adj_x(op_params->adj_x()); - op_options->set_adj_y(op_params->adj_y()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/BatchMatMul.h b/compiler/tflchef/tflite/src/Op/BatchMatMul.h deleted file mode 100644 index 6eb4c6e68..000000000 --- a/compiler/tflchef/tflite/src/Op/BatchMatMul.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_BATCHMATMUL_H__ -#define __TFLITE_OP_BATCHMATMUL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for BATCH_MATMUL - */ -class TFliteOpBatchMatMul : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_BATCHMATMUL_H__ diff --git a/compiler/tflchef/tflite/src/Op/BatchToSpaceND.cpp b/compiler/tflchef/tflite/src/Op/BatchToSpaceND.cpp deleted file mode 100644 index d5d9606d1..000000000 --- a/compiler/tflchef/tflite/src/Op/BatchToSpaceND.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "BatchToSpaceND.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpBatchToSpaceND::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second, third input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); - - tensor = import->tensors()->Get(inputs[2]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - buffer = import->buffers()->Get(tensor->buffer()); - vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[2], vec); -} - -tflchef::Operation *TFliteOpBatchToSpaceND::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("BatchToSpaceND"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/BatchToSpaceND.h b/compiler/tflchef/tflite/src/Op/BatchToSpaceND.h deleted file mode 100644 index ae2114c97..000000000 --- a/compiler/tflchef/tflite/src/Op/BatchToSpaceND.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_BATCHTOSPACEND_H__ -#define __TFLITE_OP_BATCHTOSPACEND_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for BatchToSpaceND - */ -class TFliteOpBatchToSpaceND : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_BATCHTOSPACEND_H__ diff --git a/compiler/tflchef/tflite/src/Op/Cast.cpp b/compiler/tflchef/tflite/src/Op/Cast.cpp deleted file mode 100644 index 393bb4b35..000000000 --- a/compiler/tflchef/tflite/src/Op/Cast.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Cast.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpCast::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpCast::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_CastOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Cast"); - - auto op_options = operation->mutable_cast_options(); - - op_options->set_in_data_type(as_tflchef_type(op_params->in_data_type())); - op_options->set_out_data_type(as_tflchef_type(op_params->out_data_type())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Cast.h b/compiler/tflchef/tflite/src/Op/Cast.h deleted file mode 100644 index 29c126c93..000000000 --- a/compiler/tflchef/tflite/src/Op/Cast.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_CAST_H__ -#define __TFLITE_OP_CAST_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for CAST - */ -class TFliteOpCast : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_CAST_H__ diff --git a/compiler/tflchef/tflite/src/Op/Ceil.cpp b/compiler/tflchef/tflite/src/Op/Ceil.cpp deleted file mode 100644 index d3ef3adae..000000000 --- a/compiler/tflchef/tflite/src/Op/Ceil.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Ceil.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpCeil::filler(const tflite::Operator *, TFliteImport *, tflchef::ModelRecipe *) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpCeil::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Ceil"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Ceil.h b/compiler/tflchef/tflite/src/Op/Ceil.h deleted file mode 100644 index 44df20778..000000000 --- a/compiler/tflchef/tflite/src/Op/Ceil.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_CEIL_H__ -#define __TFLITE_OP_CEIL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for CEIL - */ -class TFliteOpCeil : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_CEIL_H__ diff --git a/compiler/tflchef/tflite/src/Op/Conv2D.cpp b/compiler/tflchef/tflite/src/Op/Conv2D.cpp index 57abd4649..5d48ee24f 100644 --- a/compiler/tflchef/tflite/src/Op/Conv2D.cpp +++ b/compiler/tflchef/tflite/src/Op/Conv2D.cpp @@ -50,8 +50,7 @@ tflchef::Operation *TFliteOpConv2D::build(const tflite::Operator *op, TFliteImpo op_options->set_stride_h(op_params->stride_h()); op_options->set_stride_w(op_params->stride_w()); op_options->set_padding(as_tflchef_padding(op_params->padding())); - op_options->set_dilation_w_factor(op_params->dilation_w_factor()); - op_options->set_dilation_h_factor(op_params->dilation_h_factor()); + // TODO support dilation return operation; } diff --git a/compiler/tflchef/tflite/src/Op/Cos.cpp b/compiler/tflchef/tflite/src/Op/Cos.cpp deleted file mode 100644 index 9f2c49d49..000000000 --- a/compiler/tflchef/tflite/src/Op/Cos.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Cos.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpCos::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpCos::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Cos"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Cos.h b/compiler/tflchef/tflite/src/Op/Cos.h deleted file mode 100644 index 8f3dbe3a6..000000000 --- a/compiler/tflchef/tflite/src/Op/Cos.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_COS_H__ -#define __TFLITE_OP_COS_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Cos - */ -class TFliteOpCos : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_COS_H__ diff --git a/compiler/tflchef/tflite/src/Op/DepthToSpace.cpp b/compiler/tflchef/tflite/src/Op/DepthToSpace.cpp deleted file mode 100644 index 1a0917e8e..000000000 --- a/compiler/tflchef/tflite/src/Op/DepthToSpace.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "DepthToSpace.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpDepthToSpace::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpDepthToSpace::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("DepthToSpace"); - - auto op_params = op->builtin_options_as_DepthToSpaceOptions(); - assert(op_params != nullptr); - - auto op_options = operation->mutable_depth_to_space_options(); - - op_options->set_block_size(op_params->block_size()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/DepthToSpace.h b/compiler/tflchef/tflite/src/Op/DepthToSpace.h deleted file mode 100644 index b5852ac89..000000000 --- a/compiler/tflchef/tflite/src/Op/DepthToSpace.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_DEPTHTOSPACE_H__ -#define __TFLITE_OP_DEPTHTOSPACE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for DepthToSpace - */ -class TFliteOpDepthToSpace : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_DEPTHTOSPACE_H__ diff --git a/compiler/tflchef/tflite/src/Op/DepthwiseConv2D.cpp b/compiler/tflchef/tflite/src/Op/DepthwiseConv2D.cpp index 5fed3353a..b19f9330f 100644 --- a/compiler/tflchef/tflite/src/Op/DepthwiseConv2D.cpp +++ b/compiler/tflchef/tflite/src/Op/DepthwiseConv2D.cpp @@ -50,8 +50,9 @@ tflchef::Operation *TFliteOpDepthwiseConv2D::build(const tflite::Operator *op, T op_options->set_stride_h(op_params->stride_h()); op_options->set_stride_w(op_params->stride_w()); op_options->set_depth_multiplier(op_params->depth_multiplier()); - op_options->set_dilation_w_factor(op_params->dilation_w_factor()); - op_options->set_dilation_h_factor(op_params->dilation_h_factor()); + // TODO support dilation + // op_params->dilation_w_factor() + // op_params->dilation_h_factor() op_options->set_padding(as_tflchef_padding(op_params->padding())); return operation; diff --git a/compiler/tflchef/tflite/src/Op/Dequantize.cpp b/compiler/tflchef/tflite/src/Op/Dequantize.cpp deleted file mode 100644 index 436a0db19..000000000 --- a/compiler/tflchef/tflite/src/Op/Dequantize.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Dequantize.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpDequantize::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpDequantize::build(const tflite::Operator *, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Dequantize"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Dequantize.h b/compiler/tflchef/tflite/src/Op/Dequantize.h deleted file mode 100644 index df1c7bbdb..000000000 --- a/compiler/tflchef/tflite/src/Op/Dequantize.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_DEQUANTIZE_H__ -#define __TFLITE_OP_DEQUANTIZE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Dequantize - */ -class TFliteOpDequantize : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_DEQUANTIZE_H__ diff --git a/compiler/tflchef/tflite/src/Op/ELU.cpp b/compiler/tflchef/tflite/src/Op/ELU.cpp deleted file mode 100644 index cb4b61d66..000000000 --- a/compiler/tflchef/tflite/src/Op/ELU.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ELU.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpELU::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpELU::build(const tflite::Operator *, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("ELU"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ELU.h b/compiler/tflchef/tflite/src/Op/ELU.h deleted file mode 100644 index 490c9fde4..000000000 --- a/compiler/tflchef/tflite/src/Op/ELU.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ELU_H__ -#define __TFLITE_OP_ELU_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ELU - */ -class TFliteOpELU : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ELU_H__ diff --git a/compiler/tflchef/tflite/src/Op/Equal.cpp b/compiler/tflchef/tflite/src/Op/Equal.cpp deleted file mode 100644 index a51586228..000000000 --- a/compiler/tflchef/tflite/src/Op/Equal.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Equal.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpEqual::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpEqual::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Equal"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Equal.h b/compiler/tflchef/tflite/src/Op/Equal.h deleted file mode 100644 index fd4b40001..000000000 --- a/compiler/tflchef/tflite/src/Op/Equal.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_EQUAL_H__ -#define __TFLITE_OP_EQUAL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Equal - */ -class TFliteOpEqual : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_EQUAL_H__ diff --git a/compiler/tflchef/tflite/src/Op/Exp.cpp b/compiler/tflchef/tflite/src/Op/Exp.cpp deleted file mode 100644 index f715da6ef..000000000 --- a/compiler/tflchef/tflite/src/Op/Exp.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Exp.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpExp::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpExp::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Exp"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Exp.h b/compiler/tflchef/tflite/src/Op/Exp.h deleted file mode 100644 index 5ff3ddc8b..000000000 --- a/compiler/tflchef/tflite/src/Op/Exp.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_EXP_H__ -#define __TFLITE_OP_EXP_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Exp - */ -class TFliteOpExp : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_EXP_H__ diff --git a/compiler/tflchef/tflite/src/Op/ExpandDims.cpp b/compiler/tflchef/tflite/src/Op/ExpandDims.cpp deleted file mode 100644 index e30e8dbcc..000000000 --- a/compiler/tflchef/tflite/src/Op/ExpandDims.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ExpandDims.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpExpandDims::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Fill for axis input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpExpandDims::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("ExpandDims"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ExpandDims.h b/compiler/tflchef/tflite/src/Op/ExpandDims.h deleted file mode 100644 index e2f3e4e50..000000000 --- a/compiler/tflchef/tflite/src/Op/ExpandDims.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_EXPAND_DIMS_H__ -#define __TFLITE_OP_EXPAND_DIMS_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ExpandDims - */ -class TFliteOpExpandDims : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_EXPAND_DIMS_H__ diff --git a/compiler/tflchef/tflite/src/Op/Fill.cpp b/compiler/tflchef/tflite/src/Op/Fill.cpp deleted file mode 100644 index 08b695fd7..000000000 --- a/compiler/tflchef/tflite/src/Op/Fill.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Fill.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpFill::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const auto &inputs = *op->inputs(); - - const tflite::Tensor *dims_tensor = import->tensors()->Get(inputs[0]); - assert(dims_tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(dims_tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[0], vec); -} - -tflchef::Operation *TFliteOpFill::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("Fill"); - - // FillOptions are empty - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Fill.h b/compiler/tflchef/tflite/src/Op/Fill.h deleted file mode 100644 index 4f46f628a..000000000 --- a/compiler/tflchef/tflite/src/Op/Fill.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_FILL_H__ -#define __TFLITE_OP_FILL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Fill - */ -class TFliteOpFill : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_FILL_H__ diff --git a/compiler/tflchef/tflite/src/Op/Floor.cpp b/compiler/tflchef/tflite/src/Op/Floor.cpp deleted file mode 100644 index 373c69f71..000000000 --- a/compiler/tflchef/tflite/src/Op/Floor.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Floor.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpFloor::filler(const tflite::Operator *, TFliteImport *, tflchef::ModelRecipe *) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpFloor::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Floor"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Floor.h b/compiler/tflchef/tflite/src/Op/Floor.h deleted file mode 100644 index f0f8ef38a..000000000 --- a/compiler/tflchef/tflite/src/Op/Floor.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_FLOOR_H__ -#define __TFLITE_OP_FLOOR_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for FLOOR - */ -class TFliteOpFloor : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_FLOOR_H__ diff --git a/compiler/tflchef/tflite/src/Op/FloorDiv.cpp b/compiler/tflchef/tflite/src/Op/FloorDiv.cpp deleted file mode 100644 index 492c6941f..000000000 --- a/compiler/tflchef/tflite/src/Op/FloorDiv.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "FloorDiv.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpFloorDiv::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpFloorDiv::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("FloorDiv"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/FloorDiv.h b/compiler/tflchef/tflite/src/Op/FloorDiv.h deleted file mode 100644 index 5d049a668..000000000 --- a/compiler/tflchef/tflite/src/Op/FloorDiv.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_FLOORDIV_H__ -#define __TFLITE_OP_FLOORDIV_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for floor division - */ -class TFliteOpFloorDiv : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_FLOORDIV_H__ diff --git a/compiler/tflchef/tflite/src/Op/FloorMod.cpp b/compiler/tflchef/tflite/src/Op/FloorMod.cpp deleted file mode 100644 index 997d82664..000000000 --- a/compiler/tflchef/tflite/src/Op/FloorMod.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "FloorMod.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpFloorMod::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpFloorMod::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("FloorMod"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/FloorMod.h b/compiler/tflchef/tflite/src/Op/FloorMod.h deleted file mode 100644 index f36dfe813..000000000 --- a/compiler/tflchef/tflite/src/Op/FloorMod.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_FLOOR_MOD_H__ -#define __TFLITE_OP_FLOOR_MOD_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for FLOOR_MOD - */ -class TFliteOpFloorMod : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_FLOOR_MOD_H__ diff --git a/compiler/tflchef/tflite/src/Op/FullyConnected.cpp b/compiler/tflchef/tflite/src/Op/FullyConnected.cpp index 1f6e73aa6..4291c844b 100644 --- a/compiler/tflchef/tflite/src/Op/FullyConnected.cpp +++ b/compiler/tflchef/tflite/src/Op/FullyConnected.cpp @@ -17,7 +17,6 @@ #include "FullyConnected.h" #include "Convert.h" -#include "FillerHelper.h" namespace tflchef { @@ -25,14 +24,7 @@ namespace tflchef void TFliteOpFullyConnected::filler(const tflite::Operator *op, TFliteImport *import, tflchef::ModelRecipe *model_recipe) const { - const auto &inputs = *op->inputs(); - - for (uint32_t idx = 1; idx < inputs.size(); idx++) - { - // optional input tensor idx has minus value. - if (inputs[idx] >= 0) - fill_tensor_to_import(inputs[idx], import); - } + // Nothing to do with filler } tflchef::Operation *TFliteOpFullyConnected::build(const tflite::Operator *op, TFliteImport *import, diff --git a/compiler/tflchef/tflite/src/Op/Gather.cpp b/compiler/tflchef/tflite/src/Op/Gather.cpp deleted file mode 100644 index 98da3ec43..000000000 --- a/compiler/tflchef/tflite/src/Op/Gather.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Gather.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpGather::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler - // But second input has filler for constant inputs - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - - if (buffer && buffer->data()) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); - } -} - -tflchef::Operation *TFliteOpGather::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_GatherOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Gather"); - - auto op_options = operation->mutable_gather_options(); - - op_options->set_axis(op_params->axis()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Gather.h b/compiler/tflchef/tflite/src/Op/Gather.h deleted file mode 100644 index e01276b76..000000000 --- a/compiler/tflchef/tflite/src/Op/Gather.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_GATHER_H__ -#define __TFLITE_OP_GATHER_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Gather - */ -class TFliteOpGather : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_GATHER_H__ diff --git a/compiler/tflchef/tflite/src/Op/GatherNd.cpp b/compiler/tflchef/tflite/src/Op/GatherNd.cpp deleted file mode 100644 index 0ff5a0b7f..000000000 --- a/compiler/tflchef/tflite/src/Op/GatherNd.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "GatherNd.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpGatherNd::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // indices buffer has filler - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - - if (buffer && buffer->data()) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); - } -} - -tflchef::Operation *TFliteOpGatherNd::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("GatherNd"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/GatherNd.h b/compiler/tflchef/tflite/src/Op/GatherNd.h deleted file mode 100644 index 112f23d33..000000000 --- a/compiler/tflchef/tflite/src/Op/GatherNd.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_GATHER_ND_H__ -#define __TFLITE_OP_GATHER_ND_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for GatherNd - */ -class TFliteOpGatherNd : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_GATHER_ND_H__ diff --git a/compiler/tflchef/tflite/src/Op/Greater.cpp b/compiler/tflchef/tflite/src/Op/Greater.cpp deleted file mode 100644 index 4e41efb2d..000000000 --- a/compiler/tflchef/tflite/src/Op/Greater.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Greater.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpGreater::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpGreater::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Greater"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Greater.h b/compiler/tflchef/tflite/src/Op/Greater.h deleted file mode 100644 index 3ab2d1a4e..000000000 --- a/compiler/tflchef/tflite/src/Op/Greater.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_GREATER_H__ -#define __TFLITE_OP_GREATER_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Greater - */ -class TFliteOpGreater : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_GREATER_H__ diff --git a/compiler/tflchef/tflite/src/Op/GreaterEqual.cpp b/compiler/tflchef/tflite/src/Op/GreaterEqual.cpp deleted file mode 100644 index aead30e57..000000000 --- a/compiler/tflchef/tflite/src/Op/GreaterEqual.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "GreaterEqual.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpGreaterEqual::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpGreaterEqual::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("GreaterEqual"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/GreaterEqual.h b/compiler/tflchef/tflite/src/Op/GreaterEqual.h deleted file mode 100644 index 96b0af78a..000000000 --- a/compiler/tflchef/tflite/src/Op/GreaterEqual.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_GREATEREQUAL_H__ -#define __TFLITE_OP_GREATEREQUAL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Greater Equal - */ -class TFliteOpGreaterEqual : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_GREATEREQUAL_H__ diff --git a/compiler/tflchef/tflite/src/Op/L2Normalize.cpp b/compiler/tflchef/tflite/src/Op/L2Normalize.cpp deleted file mode 100644 index 0a8908472..000000000 --- a/compiler/tflchef/tflite/src/Op/L2Normalize.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "L2Normalize.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpL2Normalize::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpL2Normalize::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_L2NormOptions(); - auto operation = model_recipe->add_operation(); - - operation->set_type("L2Normalize"); - - auto op_options = operation->mutable_l2norm_options(); - - op_options->set_activation(as_tflchef_activation(op_params->fused_activation_function())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/L2Normalize.h b/compiler/tflchef/tflite/src/Op/L2Normalize.h deleted file mode 100644 index a73eae6c8..000000000 --- a/compiler/tflchef/tflite/src/Op/L2Normalize.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_L2NORMALIZE_H__ -#define __TFLITE_OP_L2NORMALIZE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for L2Normalize - */ -class TFliteOpL2Normalize : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_L2NORMALIZE_H__ diff --git a/compiler/tflchef/tflite/src/Op/L2Pool2D.cpp b/compiler/tflchef/tflite/src/Op/L2Pool2D.cpp deleted file mode 100644 index 8db4b02b6..000000000 --- a/compiler/tflchef/tflite/src/Op/L2Pool2D.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "L2Pool2D.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpL2Pool2D::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpL2Pool2D::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_Pool2DOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("L2Pool2D"); - - auto op_options = operation->mutable_l2pool2d_options(); - - op_options->set_padding(as_tflchef_padding(op_params->padding())); - op_options->set_stride_h(op_params->stride_h()); - op_options->set_stride_w(op_params->stride_w()); - op_options->set_filter_height(op_params->filter_height()); - op_options->set_filter_width(op_params->filter_width()); - op_options->set_activation(as_tflchef_activation(op_params->fused_activation_function())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/L2Pool2D.h b/compiler/tflchef/tflite/src/Op/L2Pool2D.h deleted file mode 100644 index 046353440..000000000 --- a/compiler/tflchef/tflite/src/Op/L2Pool2D.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_L2_POOL2D_H__ -#define __TFLITE_OP_L2_POOL2D_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for L2_POOL_2D - */ -class TFliteOpL2Pool2D : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_L2_POOL2D_H__ diff --git a/compiler/tflchef/tflite/src/Op/LeakyRelu.cpp b/compiler/tflchef/tflite/src/Op/LeakyRelu.cpp deleted file mode 100644 index bf9cb2fb3..000000000 --- a/compiler/tflchef/tflite/src/Op/LeakyRelu.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LeakyRelu.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLeakyRelu::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLeakyRelu::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_LeakyReluOptions(); - - auto operation = model_recipe->add_operation(); - - operation->set_type("LeakyRelu"); - - auto *op_options = operation->mutable_leaky_relu_options(); - - op_options->set_alpha(op_params->alpha()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/LeakyRelu.h b/compiler/tflchef/tflite/src/Op/LeakyRelu.h deleted file mode 100644 index 28e63e0ca..000000000 --- a/compiler/tflchef/tflite/src/Op/LeakyRelu.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LEAKY_RELU_H__ -#define __TFLITE_OP_LEAKY_RELU_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LeakyReLU - */ -class TFliteOpLeakyRelu : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LEAKY_RELU_H__ diff --git a/compiler/tflchef/tflite/src/Op/Less.cpp b/compiler/tflchef/tflite/src/Op/Less.cpp deleted file mode 100644 index 0360317c7..000000000 --- a/compiler/tflchef/tflite/src/Op/Less.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Less.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLess::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLess::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Less"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Less.h b/compiler/tflchef/tflite/src/Op/Less.h deleted file mode 100644 index 1316cb613..000000000 --- a/compiler/tflchef/tflite/src/Op/Less.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LESS_H__ -#define __TFLITE_OP_LESS_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Less - */ -class TFliteOpLess : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LESS_H__ diff --git a/compiler/tflchef/tflite/src/Op/LessEqual.cpp b/compiler/tflchef/tflite/src/Op/LessEqual.cpp deleted file mode 100644 index b8c42e80d..000000000 --- a/compiler/tflchef/tflite/src/Op/LessEqual.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LessEqual.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLessEqual::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLessEqual::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("LessEqual"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/LessEqual.h b/compiler/tflchef/tflite/src/Op/LessEqual.h deleted file mode 100644 index 81c710fbc..000000000 --- a/compiler/tflchef/tflite/src/Op/LessEqual.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LESSEQUAL_H__ -#define __TFLITE_OP_LESSEQUAL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LessEqual - */ -class TFliteOpLessEqual : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LESSEQUAL_H__ diff --git a/compiler/tflchef/tflite/src/Op/LocalResponseNormalization.cpp b/compiler/tflchef/tflite/src/Op/LocalResponseNormalization.cpp deleted file mode 100644 index 8bebd9e90..000000000 --- a/compiler/tflchef/tflite/src/Op/LocalResponseNormalization.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LocalResponseNormalization.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLocalResponseNormalization::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation * -TFliteOpLocalResponseNormalization::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_LocalResponseNormalizationOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("LocalResponseNormalization"); - - auto op_options = operation->mutable_local_response_normalization_options(); - - op_options->set_radius(op_params->radius()); - op_options->set_bias(op_params->bias()); - op_options->set_alpha(op_params->alpha()); - op_options->set_beta(op_params->beta()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/LocalResponseNormalization.h b/compiler/tflchef/tflite/src/Op/LocalResponseNormalization.h deleted file mode 100644 index c0eb3f2b1..000000000 --- a/compiler/tflchef/tflite/src/Op/LocalResponseNormalization.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LOCAL_RESPONSE_NORMALIZATION_H__ -#define __TFLITE_OP_LOCAL_RESPONSE_NORMALIZATION_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LocalResponseNormalization - */ -class TFliteOpLocalResponseNormalization : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LOCAL_RESPONSE_NORMALIZATION_H__ diff --git a/compiler/tflchef/tflite/src/Op/Log.cpp b/compiler/tflchef/tflite/src/Op/Log.cpp deleted file mode 100644 index a68dc9a31..000000000 --- a/compiler/tflchef/tflite/src/Op/Log.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Log.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLog::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLog::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Log"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Log.h b/compiler/tflchef/tflite/src/Op/Log.h deleted file mode 100644 index 9d17e2f81..000000000 --- a/compiler/tflchef/tflite/src/Op/Log.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LOG_H__ -#define __TFLITE_OP_LOG_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Log - */ -class TFliteOpLog : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LOG_H__ diff --git a/compiler/tflchef/tflite/src/Op/LogSoftmax.cpp b/compiler/tflchef/tflite/src/Op/LogSoftmax.cpp deleted file mode 100644 index 8f0e1a9f9..000000000 --- a/compiler/tflchef/tflite/src/Op/LogSoftmax.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogSoftmax.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLogSoftmax::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLogSoftmax::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("LogSoftmax"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/LogSoftmax.h b/compiler/tflchef/tflite/src/Op/LogSoftmax.h deleted file mode 100644 index efd81f3e9..000000000 --- a/compiler/tflchef/tflite/src/Op/LogSoftmax.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LOG_SOFTMAX_H__ -#define __TFLITE_OP_LOG_SOFTMAX_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LogSoftmax - */ -class TFliteOpLogSoftmax : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LOG_SOFTMAX_H__ diff --git a/compiler/tflchef/tflite/src/Op/LogicalAnd.cpp b/compiler/tflchef/tflite/src/Op/LogicalAnd.cpp deleted file mode 100644 index 2cc486426..000000000 --- a/compiler/tflchef/tflite/src/Op/LogicalAnd.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogicalAnd.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLogicalAnd::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLogicalAnd::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("LogicalAnd"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/LogicalAnd.h b/compiler/tflchef/tflite/src/Op/LogicalAnd.h deleted file mode 100644 index 1f7a964b9..000000000 --- a/compiler/tflchef/tflite/src/Op/LogicalAnd.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LOGICALAND_H__ -#define __TFLITE_OP_LOGICALAND_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LogicalAnd - */ -class TFliteOpLogicalAnd : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LOGICALAND_H__ diff --git a/compiler/tflchef/tflite/src/Op/LogicalNot.cpp b/compiler/tflchef/tflite/src/Op/LogicalNot.cpp deleted file mode 100644 index ecd5b903c..000000000 --- a/compiler/tflchef/tflite/src/Op/LogicalNot.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogicalNot.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLogicalNot::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLogicalNot::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("LogicalNot"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/LogicalNot.h b/compiler/tflchef/tflite/src/Op/LogicalNot.h deleted file mode 100644 index b75d33554..000000000 --- a/compiler/tflchef/tflite/src/Op/LogicalNot.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LOGICALNOT_H__ -#define __TFLITE_OP_LOGICALNOT_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LogicalNot - */ -class TFliteOpLogicalNot : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LOGICALNOT_H__ diff --git a/compiler/tflchef/tflite/src/Op/LogicalOr.cpp b/compiler/tflchef/tflite/src/Op/LogicalOr.cpp deleted file mode 100644 index b91f4cfca..000000000 --- a/compiler/tflchef/tflite/src/Op/LogicalOr.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "LogicalOr.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLogicalOr::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLogicalOr::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("LogicalOr"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/LogicalOr.h b/compiler/tflchef/tflite/src/Op/LogicalOr.h deleted file mode 100644 index 5331a0d65..000000000 --- a/compiler/tflchef/tflite/src/Op/LogicalOr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LOGICALOR_H__ -#define __TFLITE_OP_LOGICALOR_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LogicalOr - */ -class TFliteOpLogicalOr : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LOGICALOR_H__ diff --git a/compiler/tflchef/tflite/src/Op/Logistic.cpp b/compiler/tflchef/tflite/src/Op/Logistic.cpp deleted file mode 100644 index 18b3b5c00..000000000 --- a/compiler/tflchef/tflite/src/Op/Logistic.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Logistic.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpLogistic::filler(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpLogistic::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Logistic"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Logistic.h b/compiler/tflchef/tflite/src/Op/Logistic.h deleted file mode 100644 index a75bf490e..000000000 --- a/compiler/tflchef/tflite/src/Op/Logistic.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_LOGISTIC_H__ -#define __TFLITE_OP_LOGISTIC_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for LOGISTIC - */ -class TFliteOpLogistic : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_LOGISTIC_H__ diff --git a/compiler/tflchef/tflite/src/Op/MatrixDiag.cpp b/compiler/tflchef/tflite/src/Op/MatrixDiag.cpp deleted file mode 100644 index ca84c4949..000000000 --- a/compiler/tflchef/tflite/src/Op/MatrixDiag.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MatrixDiag.h" - -namespace tflchef -{ - -void TFliteOpMatrixDiag::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpMatrixDiag::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("MatrixDiag"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/MatrixDiag.h b/compiler/tflchef/tflite/src/Op/MatrixDiag.h deleted file mode 100644 index 4074f2c36..000000000 --- a/compiler/tflchef/tflite/src/Op/MatrixDiag.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_MATRIX_DIAG_H__ -#define __TFLITE_OP_MATRIX_DIAG_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for MatrixDiag - */ -class TFliteOpMatrixDiag : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_MATRIX_DIAG_H__ diff --git a/compiler/tflchef/tflite/src/Op/MatrixSetDiag.cpp b/compiler/tflchef/tflite/src/Op/MatrixSetDiag.cpp deleted file mode 100644 index 97c7de41f..000000000 --- a/compiler/tflchef/tflite/src/Op/MatrixSetDiag.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MatrixSetDiag.h" - -namespace tflchef -{ - -void TFliteOpMatrixSetDiag::filler(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpMatrixSetDiag::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("MatrixSetDiag"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/MatrixSetDiag.h b/compiler/tflchef/tflite/src/Op/MatrixSetDiag.h deleted file mode 100644 index 0e7ec7f32..000000000 --- a/compiler/tflchef/tflite/src/Op/MatrixSetDiag.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_MATRIX_SET_DIAG_H__ -#define __TFLITE_OP_MATRIX_SET_DIAG_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for MatrixSetDiag - */ -class TFliteOpMatrixSetDiag : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_MATRIX_SET_DIAG_H__ diff --git a/compiler/tflchef/tflite/src/Op/Maximum.cpp b/compiler/tflchef/tflite/src/Op/Maximum.cpp deleted file mode 100644 index fb977b6ed..000000000 --- a/compiler/tflchef/tflite/src/Op/Maximum.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Maximum.h" - -namespace tflchef -{ - -void TFliteOpMaximum::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpMaximum::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Maximum"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Maximum.h b/compiler/tflchef/tflite/src/Op/Maximum.h deleted file mode 100644 index acafec343..000000000 --- a/compiler/tflchef/tflite/src/Op/Maximum.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_MAXIMUM_H__ -#define __TFLITE_OP_MAXIMUM_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for maximum - */ -class TFliteOpMaximum : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_MAXIMUM_H__ diff --git a/compiler/tflchef/tflite/src/Op/Mean.cpp b/compiler/tflchef/tflite/src/Op/Mean.cpp deleted file mode 100644 index 1c2975781..000000000 --- a/compiler/tflchef/tflite/src/Op/Mean.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Mean.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpMean::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpMean::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ReducerOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Mean"); - - auto op_options = operation->mutable_mean_options(); - - op_options->set_keep_dims(op_params->keep_dims()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Mean.h b/compiler/tflchef/tflite/src/Op/Mean.h deleted file mode 100644 index 532c40c66..000000000 --- a/compiler/tflchef/tflite/src/Op/Mean.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_MEAN_H__ -#define __TFLITE_OP_MEAN_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for mean - */ -class TFliteOpMean : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_MEAN_H__ diff --git a/compiler/tflchef/tflite/src/Op/Minimum.cpp b/compiler/tflchef/tflite/src/Op/Minimum.cpp deleted file mode 100644 index 2bb50cb89..000000000 --- a/compiler/tflchef/tflite/src/Op/Minimum.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Minimum.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpMinimum::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpMinimum::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Minimum"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Minimum.h b/compiler/tflchef/tflite/src/Op/Minimum.h deleted file mode 100644 index 5db5b7940..000000000 --- a/compiler/tflchef/tflite/src/Op/Minimum.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_MINIMUM_H__ -#define __TFLITE_OP_MINIMUM_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for minimum - */ -class TFliteOpMinimum : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_MINIMUM_H__ diff --git a/compiler/tflchef/tflite/src/Op/MirrorPad.cpp b/compiler/tflchef/tflite/src/Op/MirrorPad.cpp deleted file mode 100644 index c688552ee..000000000 --- a/compiler/tflchef/tflite/src/Op/MirrorPad.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "MirrorPad.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpMirrorPad::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpMirrorPad::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("MirrorPad"); - - auto op_options = operation->mutable_mirrorpad_options(); - - auto op_params = op->builtin_options_as_MirrorPadOptions(); - assert(op_params != nullptr); - - op_options->set_mode(as_tflchef_mirrorpadmode(op_params->mode())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/MirrorPad.h b/compiler/tflchef/tflite/src/Op/MirrorPad.h deleted file mode 100644 index c9acdd498..000000000 --- a/compiler/tflchef/tflite/src/Op/MirrorPad.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_MIRROR_PAD_H__ -#define __TFLITE_OP_MIRROR_PAD_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for MIRROR_PAD - */ -class TFliteOpMirrorPad : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_MIRROR_PAD_H__ diff --git a/compiler/tflchef/tflite/src/Op/Mul.cpp b/compiler/tflchef/tflite/src/Op/Mul.cpp deleted file mode 100644 index 9faa4acaf..000000000 --- a/compiler/tflchef/tflite/src/Op/Mul.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Mul.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpMul::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Mul may have constant input - - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - assert(inputs.size() == 2); - - fill_tensor_to_import(inputs[0], import); - fill_tensor_to_import(inputs[1], import); -} - -tflchef::Operation *TFliteOpMul::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Mul"); - - auto op_params = op->builtin_options_as_MulOptions(); - assert(op_params != nullptr); - - auto op_options = operation->mutable_mul_options(); - op_options->set_activation(as_tflchef_activation(op_params->fused_activation_function())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Mul.h b/compiler/tflchef/tflite/src/Op/Mul.h deleted file mode 100644 index fd009d2fd..000000000 --- a/compiler/tflchef/tflite/src/Op/Mul.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_MUL_H__ -#define __TFLITE_OP_MUL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for MUL - */ -class TFliteOpMul : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_MUL_H__ diff --git a/compiler/tflchef/tflite/src/Op/Neg.cpp b/compiler/tflchef/tflite/src/Op/Neg.cpp deleted file mode 100644 index c691390a3..000000000 --- a/compiler/tflchef/tflite/src/Op/Neg.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Neg.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpNeg::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpNeg::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Neg"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Neg.h b/compiler/tflchef/tflite/src/Op/Neg.h deleted file mode 100644 index c77ab7e84..000000000 --- a/compiler/tflchef/tflite/src/Op/Neg.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_NEG_H__ -#define __TFLITE_OP_NEG_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for abs - */ -class TFliteOpNeg : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_NEG_H__ diff --git a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV4.cpp b/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV4.cpp deleted file mode 100644 index ad9921970..000000000 --- a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV4.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "NonMaxSuppressionV4.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpNonMaxSuppressionV4::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const auto &inputs = *op->inputs(); - - const tflite::Tensor *max_output_size_tensor = import->tensors()->Get(inputs[2]); - assert(max_output_size_tensor->type() == tflite::TensorType::TensorType_INT32); - - const tflite::Tensor *iou_threshold_tensor = import->tensors()->Get(inputs[3]); - assert(iou_threshold_tensor->type() == tflite::TensorType::TensorType_FLOAT32); - - const tflite::Tensor *score_threshold_tensor = import->tensors()->Get(inputs[4]); - assert(score_threshold_tensor->type() == tflite::TensorType::TensorType_FLOAT32); - - for (int32_t index = 2; index < 5; ++index) - { - fill_tensor_to_import(index, import); - } -} - -tflchef::Operation *TFliteOpNonMaxSuppressionV4::build(const tflite::Operator *op, - TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("NonMaxSuppressionV4"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV4.h b/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV4.h deleted file mode 100644 index 114a2ad2f..000000000 --- a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV4.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_NON_MAX_SUPPRESSION_V4_H__ -#define __TFLITE_OP_NON_MAX_SUPPRESSION_V4_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for NON_MAX_SUPPRESSION_V4 - */ -class TFliteOpNonMaxSuppressionV4 : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_NON_MAX_SUPPRESSION_V4_H__ diff --git a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV5.cpp b/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV5.cpp deleted file mode 100644 index db7f4c932..000000000 --- a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV5.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "NonMaxSuppressionV5.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpNonMaxSuppressionV5::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const auto &inputs = *op->inputs(); - - const tflite::Tensor *max_output_size_tensor = import->tensors()->Get(inputs[2]); - assert(max_output_size_tensor->type() == tflite::TensorType::TensorType_INT32); - - const tflite::Tensor *iou_threshold_tensor = import->tensors()->Get(inputs[3]); - assert(iou_threshold_tensor->type() == tflite::TensorType::TensorType_FLOAT32); - - const tflite::Tensor *score_threshold_tensor = import->tensors()->Get(inputs[4]); - assert(score_threshold_tensor->type() == tflite::TensorType::TensorType_FLOAT32); - - const tflite::Tensor *soft_nms_sigma_tensor = import->tensors()->Get(inputs[5]); - assert(soft_nms_sigma_tensor->type() == tflite::TensorType::TensorType_FLOAT32); - - for (int32_t index = 2; index < 6; ++index) - { - fill_tensor_to_import(index, import); - } -} - -tflchef::Operation *TFliteOpNonMaxSuppressionV5::build(const tflite::Operator *op, - TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("NonMaxSuppressionV5"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV5.h b/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV5.h deleted file mode 100644 index c948043f4..000000000 --- a/compiler/tflchef/tflite/src/Op/NonMaxSuppressionV5.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_NON_MAX_SUPPRESSION_V5_H__ -#define __TFLITE_OP_NON_MAX_SUPPRESSION_V5_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for NON_MAX_SUPPRESSION_V5 - */ -class TFliteOpNonMaxSuppressionV5 : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_NON_MAX_SUPPRESSION_V5_H__ diff --git a/compiler/tflchef/tflite/src/Op/NotEqual.cpp b/compiler/tflchef/tflite/src/Op/NotEqual.cpp deleted file mode 100644 index c2275db06..000000000 --- a/compiler/tflchef/tflite/src/Op/NotEqual.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "NotEqual.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpNotEqual::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpNotEqual::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("NotEqual"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/NotEqual.h b/compiler/tflchef/tflite/src/Op/NotEqual.h deleted file mode 100644 index b1febdcc5..000000000 --- a/compiler/tflchef/tflite/src/Op/NotEqual.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_NOTEQUAL_H__ -#define __TFLITE_OP_NOTEQUAL_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Not Equal - */ -class TFliteOpNotEqual : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_NOTEQUAL_H__ diff --git a/compiler/tflchef/tflite/src/Op/OneHot.cpp b/compiler/tflchef/tflite/src/Op/OneHot.cpp deleted file mode 100644 index f26ed3e7f..000000000 --- a/compiler/tflchef/tflite/src/Op/OneHot.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "OneHot.h" -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpOneHot::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // only depth(second input) has constant on recipe cause depth value is used in shape inference. - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - - if (buffer && buffer->data()) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); - } - - // on/off can be dtype of input/output. let's support INT32/FLOAT32 for now - for (int32_t index = 2; index <= 3; ++index) - { - const tflite::Tensor *tensor = import->tensors()->Get(inputs[index]); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - if (buffer && buffer->data()) - { - switch (tensor->type()) - { - case tflite::TensorType::TensorType_INT32: - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[index], vec); - break; - } - - case tflite::TensorType::TensorType_FLOAT32: - { - auto vec = extract_buffer<float>(buffer); - import->set_tensor_filler(inputs[index], vec); - break; - } - - default: - assert(false); - break; - } - } - } -} - -tflchef::Operation *TFliteOpOneHot::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_OneHotOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("OneHot"); - - auto op_options = operation->mutable_onehot_options(); - - op_options->set_axis(op_params->axis()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/OneHot.h b/compiler/tflchef/tflite/src/Op/OneHot.h deleted file mode 100644 index 50bbed095..000000000 --- a/compiler/tflchef/tflite/src/Op/OneHot.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ONEHOT_H__ -#define __TFLITE_OP_ONEHOT_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for OneHot - */ -class TFliteOpOneHot : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ONEHOT_H__ diff --git a/compiler/tflchef/tflite/src/Op/PRelu.cpp b/compiler/tflchef/tflite/src/Op/PRelu.cpp deleted file mode 100644 index 8a5e83a84..000000000 --- a/compiler/tflchef/tflite/src/Op/PRelu.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "PRelu.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpPRelu::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ -} - -tflchef::Operation *TFliteOpPRelu::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("PRelu"); - - // PReluOptions are empty - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/PRelu.h b/compiler/tflchef/tflite/src/Op/PRelu.h deleted file mode 100644 index b35c6e7ce..000000000 --- a/compiler/tflchef/tflite/src/Op/PRelu.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_PRELU_H__ -#define __TFLITE_OP_PRELU_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for PRelu - */ -class TFliteOpPRelu : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_PRELU_H__ diff --git a/compiler/tflchef/tflite/src/Op/Pack.cpp b/compiler/tflchef/tflite/src/Op/Pack.cpp deleted file mode 100644 index ddf8c7d5d..000000000 --- a/compiler/tflchef/tflite/src/Op/Pack.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Pack.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpPack::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpPack::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_PackOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Pack"); - - auto op_options = operation->mutable_pack_options(); - - op_options->set_axis(op_params->axis()); - op_options->set_values_count(op_params->values_count()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Pack.h b/compiler/tflchef/tflite/src/Op/Pack.h deleted file mode 100644 index 7779f64ed..000000000 --- a/compiler/tflchef/tflite/src/Op/Pack.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_PACK_H__ -#define __TFLITE_OP_PACK_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for pack - */ -class TFliteOpPack : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_PACK_H__ diff --git a/compiler/tflchef/tflite/src/Op/Pad.cpp b/compiler/tflchef/tflite/src/Op/Pad.cpp deleted file mode 100644 index 2978e4422..000000000 --- a/compiler/tflchef/tflite/src/Op/Pad.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Pad.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpPad::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpPad::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Pad"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Pad.h b/compiler/tflchef/tflite/src/Op/Pad.h deleted file mode 100644 index 99998d418..000000000 --- a/compiler/tflchef/tflite/src/Op/Pad.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_PAD_H__ -#define __TFLITE_OP_PAD_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for PAD - */ -class TFliteOpPad : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_PAD_H__ diff --git a/compiler/tflchef/tflite/src/Op/PadV2.cpp b/compiler/tflchef/tflite/src/Op/PadV2.cpp deleted file mode 100644 index 0b1c9f3b2..000000000 --- a/compiler/tflchef/tflite/src/Op/PadV2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "PadV2.h" - -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpPadV2::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Filler for paddings and constant_values - fill_tensor_to_import(1, import); - fill_tensor_to_import(2, import); -} - -tflchef::Operation *TFliteOpPadV2::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("PadV2"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/PadV2.h b/compiler/tflchef/tflite/src/Op/PadV2.h deleted file mode 100644 index 3aa474b92..000000000 --- a/compiler/tflchef/tflite/src/Op/PadV2.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_PADV2_H__ -#define __TFLITE_OP_PADV2_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for PADV2 - */ -class TFliteOpPadV2 : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_PADV2_H__ diff --git a/compiler/tflchef/tflite/src/Op/Pow.cpp b/compiler/tflchef/tflite/src/Op/Pow.cpp deleted file mode 100644 index fe8e8ac0f..000000000 --- a/compiler/tflchef/tflite/src/Op/Pow.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Pow.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpPow::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ -} - -tflchef::Operation *TFliteOpPow::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("Pow"); - - // PowOptions are empty - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Pow.h b/compiler/tflchef/tflite/src/Op/Pow.h deleted file mode 100644 index 20e847377..000000000 --- a/compiler/tflchef/tflite/src/Op/Pow.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_POW_H__ -#define __TFLITE_OP_POW_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Pow - */ -class TFliteOpPow : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_POW_H__ diff --git a/compiler/tflchef/tflite/src/Op/Range.cpp b/compiler/tflchef/tflite/src/Op/Range.cpp deleted file mode 100644 index 2958b9c41..000000000 --- a/compiler/tflchef/tflite/src/Op/Range.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Range.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpRange::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for all inputs - const auto &inputs = *op->inputs(); - - for (int index = 0; index < 3; ++index) - { - const tflite::Tensor *tensor = import->tensors()->Get(inputs[index]); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - if (tensor->type() == tflite::TensorType::TensorType_INT32) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[index], vec); - } - else if (tensor->type() == tflite::TensorType::TensorType_FLOAT32) - { - auto vec = extract_buffer<float>(buffer); - import->set_tensor_filler(inputs[index], vec); - } - else - { - assert(false && "Invalid tensor type"); - } - } -} - -tflchef::Operation *TFliteOpRange::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Range"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Range.h b/compiler/tflchef/tflite/src/Op/Range.h deleted file mode 100644 index ad10dc58b..000000000 --- a/compiler/tflchef/tflite/src/Op/Range.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_RANGE_H__ -#define __TFLITE_OP_RANGE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for abs - */ -class TFliteOpRange : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_RANGE_H__ diff --git a/compiler/tflchef/tflite/src/Op/Rank.cpp b/compiler/tflchef/tflite/src/Op/Rank.cpp deleted file mode 100644 index 184c8e482..000000000 --- a/compiler/tflchef/tflite/src/Op/Rank.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Rank.h" - -namespace tflchef -{ - -void TFliteOpRank::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpRank::build(const tflite::Operator *, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Rank"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Rank.h b/compiler/tflchef/tflite/src/Op/Rank.h deleted file mode 100644 index 003d9d310..000000000 --- a/compiler/tflchef/tflite/src/Op/Rank.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_RANK_H__ -#define __TFLITE_OP_RANK_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for rank - */ -class TFliteOpRank : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_RANK_H__ diff --git a/compiler/tflchef/tflite/src/Op/ReLUN1To1.cpp b/compiler/tflchef/tflite/src/Op/ReLUN1To1.cpp deleted file mode 100644 index 4cc8dbd2b..000000000 --- a/compiler/tflchef/tflite/src/Op/ReLUN1To1.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReLUN1To1.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpReLUN1To1::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpReLUN1To1::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("ReLUN1To1"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ReLUN1To1.h b/compiler/tflchef/tflite/src/Op/ReLUN1To1.h deleted file mode 100644 index 0767006af..000000000 --- a/compiler/tflchef/tflite/src/Op/ReLUN1To1.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_RELU_N1_TO_1_H__ -#define __TFLITE_OP_RELU_N1_TO_1_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for RELU_N1_TO_1 - */ -class TFliteOpReLUN1To1 : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_RELU_N1_TO_1_H__ diff --git a/compiler/tflchef/tflite/src/Op/ReduceAny.cpp b/compiler/tflchef/tflite/src/Op/ReduceAny.cpp deleted file mode 100644 index e0cc503c4..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceAny.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceAny.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpReduceAny::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpReduceAny::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("ReduceAny"); - - auto op_params = op->builtin_options_as_ReducerOptions(); - assert(op_params != nullptr); - - auto op_options = operation->mutable_reduce_any_options(); - op_options->set_keep_dims(op_params->keep_dims()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ReduceAny.h b/compiler/tflchef/tflite/src/Op/ReduceAny.h deleted file mode 100644 index dd5e361d5..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceAny.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_REDUCE_ANY_H__ -#define __TFLITE_OP_REDUCE_ANY_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for REDUCE_ANY - */ -class TFliteOpReduceAny : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_REDUCE_ANY_H__ diff --git a/compiler/tflchef/tflite/src/Op/ReduceMax.cpp b/compiler/tflchef/tflite/src/Op/ReduceMax.cpp deleted file mode 100644 index 499f58566..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceMax.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceMax.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpReduceMax::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpReduceMax::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ReducerOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("ReduceMax"); - - auto op_options = operation->mutable_reduce_max_options(); - - op_options->set_keep_dims(op_params->keep_dims()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ReduceMax.h b/compiler/tflchef/tflite/src/Op/ReduceMax.h deleted file mode 100644 index 8e65cf47c..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceMax.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_REDUCEMAX_H__ -#define __TFLITE_OP_REDUCEMAX_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Reduce Max - */ -class TFliteOpReduceMax : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_REDUCEMAX_H__ diff --git a/compiler/tflchef/tflite/src/Op/ReduceMin.cpp b/compiler/tflchef/tflite/src/Op/ReduceMin.cpp deleted file mode 100644 index 09e2e134c..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceMin.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceMin.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpReduceMin::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpReduceMin::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ReducerOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("ReduceMin"); - - auto op_options = operation->mutable_reduce_min_options(); - - op_options->set_keep_dims(op_params->keep_dims()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ReduceMin.h b/compiler/tflchef/tflite/src/Op/ReduceMin.h deleted file mode 100644 index 88cba6fe7..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceMin.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_REDUCEMIN_H__ -#define __TFLITE_OP_REDUCEMIN_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Reduce Min - */ -class TFliteOpReduceMin : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_REDUCEMIN_H__ diff --git a/compiler/tflchef/tflite/src/Op/ReduceProd.cpp b/compiler/tflchef/tflite/src/Op/ReduceProd.cpp deleted file mode 100644 index e2d98970d..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceProd.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReduceProd.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpReduceProd::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpReduceProd::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("ReduceProd"); - - auto op_params = op->builtin_options_as_ReducerOptions(); - assert(op_params != nullptr); - - auto op_options = operation->mutable_reduce_prod_options(); - op_options->set_keep_dims(op_params->keep_dims()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ReduceProd.h b/compiler/tflchef/tflite/src/Op/ReduceProd.h deleted file mode 100644 index e7766840a..000000000 --- a/compiler/tflchef/tflite/src/Op/ReduceProd.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_REDUCE_PROD_H__ -#define __TFLITE_OP_REDUCE_PROD_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for REDUCE_PROD - */ -class TFliteOpReduceProd : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_REDUCE_PROD_H__ diff --git a/compiler/tflchef/tflite/src/Op/Reshape.cpp b/compiler/tflchef/tflite/src/Op/Reshape.cpp index 0094d5df5..663ab3ec3 100644 --- a/compiler/tflchef/tflite/src/Op/Reshape.cpp +++ b/compiler/tflchef/tflite/src/Op/Reshape.cpp @@ -17,7 +17,6 @@ #include "Reshape.h" #include "Convert.h" -#include "FillerHelper.h" namespace tflchef { @@ -28,29 +27,33 @@ void TFliteOpReshape::filler(const tflite::Operator *op, TFliteImport *import, const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); bool hasShape = (inputs.size() == 2); + assert(inputs.size() == 1 || hasShape); + if (hasShape) { - fill_tensor_to_import(inputs[1], import); + auto op_params = op->builtin_options_as_ReshapeOptions(); + std::vector<int32_t> new_shape = as_index_vector(op_params->new_shape()); + import->set_tensor_filler(inputs.at(1), new_shape); } } tflchef::Operation *TFliteOpReshape::build(const tflite::Operator *op, TFliteImport *import, tflchef::ModelRecipe *model_recipe) const { + auto op_params = op->builtin_options_as_ReshapeOptions(); + assert(op_params != nullptr); + auto operation = model_recipe->add_operation(); operation->set_type("Reshape"); - auto op_params = op->builtin_options_as_ReshapeOptions(); - if (op_params != nullptr) - { - auto op_options = operation->mutable_reshape_options(); + auto op_options = operation->mutable_reshape_options(); - std::vector<int32_t> new_shape = as_index_vector(op_params->new_shape()); - for (auto shape : new_shape) - { - op_options->add_new_shape(shape); - } + std::vector<int32_t> new_shape = as_index_vector(op_params->new_shape()); + + for (auto shape : new_shape) + { + op_options->add_new_shape(shape); } return operation; diff --git a/compiler/tflchef/tflite/src/Op/ResizeBilinear.cpp b/compiler/tflchef/tflite/src/Op/ResizeBilinear.cpp deleted file mode 100644 index 0f6db1fcb..000000000 --- a/compiler/tflchef/tflite/src/Op/ResizeBilinear.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ResizeBilinear.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpResizeBilinear::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // size buffer has filler - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - - if (buffer && buffer->data()) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); - } -} - -tflchef::Operation *TFliteOpResizeBilinear::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ResizeBilinearOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("ResizeBilinear"); - - auto op_options = operation->mutable_resize_bilinear_options(); - - op_options->set_align_corners(op_params->align_corners()); - op_options->set_half_pixel_centers(op_params->half_pixel_centers()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ResizeBilinear.h b/compiler/tflchef/tflite/src/Op/ResizeBilinear.h deleted file mode 100644 index 98c49c534..000000000 --- a/compiler/tflchef/tflite/src/Op/ResizeBilinear.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_RESIZE_BILINEAR_H__ -#define __TFLITE_OP_RESIZE_BILINEAR_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ResizeBilinear - */ -class TFliteOpResizeBilinear : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_RESIZE_BILINEAR_H__ diff --git a/compiler/tflchef/tflite/src/Op/ResizeNearestNeighbor.cpp b/compiler/tflchef/tflite/src/Op/ResizeNearestNeighbor.cpp deleted file mode 100644 index f3dd8fed0..000000000 --- a/compiler/tflchef/tflite/src/Op/ResizeNearestNeighbor.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ResizeNearestNeighbor.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpResizeNearestNeighbor::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // size buffer has filler - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - - if (buffer && buffer->data()) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); - } -} - -tflchef::Operation *TFliteOpResizeNearestNeighbor::build(const tflite::Operator *op, - TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ResizeNearestNeighborOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("ResizeNearestNeighbor"); - - auto op_options = operation->mutable_resize_nearest_neighbor_options(); - - op_options->set_align_corners(op_params->align_corners()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ResizeNearestNeighbor.h b/compiler/tflchef/tflite/src/Op/ResizeNearestNeighbor.h deleted file mode 100644 index 5090bb938..000000000 --- a/compiler/tflchef/tflite/src/Op/ResizeNearestNeighbor.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_RESIZE_NEAREST_NEIGHBOR_H__ -#define __TFLITE_OP_RESIZE_NEAREST_NEIGHBOR_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ResizeNearestNeighbor - */ -class TFliteOpResizeNearestNeighbor : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_RESIZE_NEAREST_NEIGHBOR_H__ diff --git a/compiler/tflchef/tflite/src/Op/ReverseSequence.cpp b/compiler/tflchef/tflite/src/Op/ReverseSequence.cpp deleted file mode 100644 index 6ef6c2326..000000000 --- a/compiler/tflchef/tflite/src/Op/ReverseSequence.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReverseSequence.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpReverseSequence::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *) const -{ - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - assert(inputs.size() == 2); - - fill_tensor_to_import(inputs[1], import); -} - -tflchef::Operation *TFliteOpReverseSequence::build(const tflite::Operator *op, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("ReverseSequence"); - - auto op_params = op->builtin_options_as_ReverseSequenceOptions(); - - assert(op_params != nullptr); - - auto op_options = operation->mutable_reverse_sequence_options(); - - op_options->set_seq_dim(op_params->seq_dim()); - op_options->set_batch_dim(op_params->batch_dim()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ReverseSequence.h b/compiler/tflchef/tflite/src/Op/ReverseSequence.h deleted file mode 100644 index 8c8c811e4..000000000 --- a/compiler/tflchef/tflite/src/Op/ReverseSequence.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_REVERSE_SEQUENCE_H__ -#define __TFLITE_OP_REVERSE_SEQUENCE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ReverseSequence - */ -class TFliteOpReverseSequence : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_REVERSE_SEQUENCE_H__ diff --git a/compiler/tflchef/tflite/src/Op/ReverseV2.cpp b/compiler/tflchef/tflite/src/Op/ReverseV2.cpp deleted file mode 100644 index c59d97574..000000000 --- a/compiler/tflchef/tflite/src/Op/ReverseV2.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ReverseV2.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpReverseV2::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *) const -{ - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - assert(inputs.size() == 2); - - fill_tensor_to_import(inputs[1], import); -} - -tflchef::Operation *TFliteOpReverseV2::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("ReverseV2"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ReverseV2.h b/compiler/tflchef/tflite/src/Op/ReverseV2.h deleted file mode 100644 index 6a8a75e6b..000000000 --- a/compiler/tflchef/tflite/src/Op/ReverseV2.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_REVERSEV2_H__ -#define __TFLITE_OP_REVERSEV2_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ReverseV2 - */ -class TFliteOpReverseV2 : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_REVERSEV2_H__ diff --git a/compiler/tflchef/tflite/src/Op/Round.cpp b/compiler/tflchef/tflite/src/Op/Round.cpp deleted file mode 100644 index c3f6bf6c4..000000000 --- a/compiler/tflchef/tflite/src/Op/Round.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Round.h" - -namespace tflchef -{ - -void TFliteOpRound::filler(const tflite::Operator *, TFliteImport *, tflchef::ModelRecipe *) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpRound::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Round"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Round.h b/compiler/tflchef/tflite/src/Op/Round.h deleted file mode 100644 index df0da3fa1..000000000 --- a/compiler/tflchef/tflite/src/Op/Round.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ROUND_H__ -#define __TFLITE_OP_ROUND_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Round - */ -class TFliteOpRound : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ROUND_H__ diff --git a/compiler/tflchef/tflite/src/Op/Rsqrt.cpp b/compiler/tflchef/tflite/src/Op/Rsqrt.cpp deleted file mode 100644 index 1639214e4..000000000 --- a/compiler/tflchef/tflite/src/Op/Rsqrt.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Rsqrt.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpRsqrt::filler(const tflite::Operator *, TFliteImport *, tflchef::ModelRecipe *) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpRsqrt::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Rsqrt"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Rsqrt.h b/compiler/tflchef/tflite/src/Op/Rsqrt.h deleted file mode 100644 index 5d68344c2..000000000 --- a/compiler/tflchef/tflite/src/Op/Rsqrt.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_RSQRT_H__ -#define __TFLITE_OP_RSQRT_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Rsqrt - */ -class TFliteOpRsqrt : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_RSQRT_H__ diff --git a/compiler/tflchef/tflite/src/Op/ScatterNd.cpp b/compiler/tflchef/tflite/src/Op/ScatterNd.cpp deleted file mode 100644 index 548a09a67..000000000 --- a/compiler/tflchef/tflite/src/Op/ScatterNd.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ScatterNd.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpScatterNd::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Filler for indices and shape - fill_tensor_to_import(0, import); - fill_tensor_to_import(2, import); -} - -tflchef::Operation *TFliteOpScatterNd::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("ScatterNd"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ScatterNd.h b/compiler/tflchef/tflite/src/Op/ScatterNd.h deleted file mode 100644 index 76362d775..000000000 --- a/compiler/tflchef/tflite/src/Op/ScatterNd.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SCATTER_ND_H__ -#define __TFLITE_OP_SCATTER_ND_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ScatterNd - */ -class TFliteOpScatterNd : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SCATTER_ND_H__ diff --git a/compiler/tflchef/tflite/src/Op/SegmentSum.cpp b/compiler/tflchef/tflite/src/Op/SegmentSum.cpp deleted file mode 100644 index a975ca4b3..000000000 --- a/compiler/tflchef/tflite/src/Op/SegmentSum.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SegmentSum.h" - -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpSegmentSum::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Filler for indices and shape - fill_tensor_to_import(1, import); -} - -tflchef::Operation *TFliteOpSegmentSum::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("SegmentSum"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SegmentSum.h b/compiler/tflchef/tflite/src/Op/SegmentSum.h deleted file mode 100644 index d20e63bd7..000000000 --- a/compiler/tflchef/tflite/src/Op/SegmentSum.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SEGMENT_SUM_H__ -#define __TFLITE_OP_SEGMENT_SUM_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SEGMENT_SUM - */ -class TFliteOpSegmentSum : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SEGMENT_SUM_H__ diff --git a/compiler/tflchef/tflite/src/Op/Select.cpp b/compiler/tflchef/tflite/src/Op/Select.cpp deleted file mode 100644 index 741ffb8f6..000000000 --- a/compiler/tflchef/tflite/src/Op/Select.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Select.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSelect::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSelect::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Select"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Select.h b/compiler/tflchef/tflite/src/Op/Select.h deleted file mode 100644 index bf8e57d78..000000000 --- a/compiler/tflchef/tflite/src/Op/Select.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SELECT_H__ -#define __TFLITE_OP_SELECT_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SELECT - */ -class TFliteOpSelect : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SELECT_H__ diff --git a/compiler/tflchef/tflite/src/Op/SelectV2.cpp b/compiler/tflchef/tflite/src/Op/SelectV2.cpp deleted file mode 100644 index 0ddabb4be..000000000 --- a/compiler/tflchef/tflite/src/Op/SelectV2.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SelectV2.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSelectV2::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSelectV2::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("SelectV2"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SelectV2.h b/compiler/tflchef/tflite/src/Op/SelectV2.h deleted file mode 100644 index ff03341d7..000000000 --- a/compiler/tflchef/tflite/src/Op/SelectV2.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SELECT_V2_H__ -#define __TFLITE_OP_SELECT_V2_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SELECT - */ -class TFliteOpSelectV2 : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SELECT_V2_H__ diff --git a/compiler/tflchef/tflite/src/Op/Shape.cpp b/compiler/tflchef/tflite/src/Op/Shape.cpp deleted file mode 100644 index d6e490d63..000000000 --- a/compiler/tflchef/tflite/src/Op/Shape.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Shape.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpShape::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpShape::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("Shape"); - - auto op_params = op->builtin_options_as_ShapeOptions(); - assert(op_params != nullptr); - - auto op_options = operation->mutable_shape_options(); - op_options->set_out_type(as_tflchef_type(op_params->out_type())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Shape.h b/compiler/tflchef/tflite/src/Op/Shape.h deleted file mode 100644 index ebe1befb3..000000000 --- a/compiler/tflchef/tflite/src/Op/Shape.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SHAPE_H__ -#define __TFLITE_OP_SHAPE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SHAPE - */ -class TFliteOpShape : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SHAPE_H__ diff --git a/compiler/tflchef/tflite/src/Op/Sin.cpp b/compiler/tflchef/tflite/src/Op/Sin.cpp deleted file mode 100644 index 8c063f424..000000000 --- a/compiler/tflchef/tflite/src/Op/Sin.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Sin.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSin::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSin::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Sin"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Sin.h b/compiler/tflchef/tflite/src/Op/Sin.h deleted file mode 100644 index 51eabceb5..000000000 --- a/compiler/tflchef/tflite/src/Op/Sin.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SIN_H__ -#define __TFLITE_OP_SIN_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Sin - */ -class TFliteOpSin : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SIN_H__ diff --git a/compiler/tflchef/tflite/src/Op/Slice.cpp b/compiler/tflchef/tflite/src/Op/Slice.cpp deleted file mode 100644 index f0c44da2d..000000000 --- a/compiler/tflchef/tflite/src/Op/Slice.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Slice.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSlice::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - - // for begin and size - for (int32_t index = 1; index <= 2; ++index) - { - const tflite::Tensor *tensor = import->tensors()->Get(inputs[index]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[index], vec); - } -} - -tflchef::Operation *TFliteOpSlice::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Slice"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Slice.h b/compiler/tflchef/tflite/src/Op/Slice.h deleted file mode 100644 index 6ca6724d3..000000000 --- a/compiler/tflchef/tflite/src/Op/Slice.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SLICE_H__ -#define __TFLITE_OP_SLICE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SLICE - */ -class TFliteOpSlice : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SLICE_H__ diff --git a/compiler/tflchef/tflite/src/Op/Softmax.cpp b/compiler/tflchef/tflite/src/Op/Softmax.cpp deleted file mode 100644 index 5b5c94f7e..000000000 --- a/compiler/tflchef/tflite/src/Op/Softmax.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Softmax.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSoftmax::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSoftmax::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_SoftmaxOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Softmax"); - - auto op_options = operation->mutable_softmax_options(); - - op_options->set_beta(op_params->beta()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SpaceToBatchND.cpp b/compiler/tflchef/tflite/src/Op/SpaceToBatchND.cpp deleted file mode 100644 index 9de0775a9..000000000 --- a/compiler/tflchef/tflite/src/Op/SpaceToBatchND.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SpaceToBatchND.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSpaceToBatchND::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second, third input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); - - tensor = import->tensors()->Get(inputs[2]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - buffer = import->buffers()->Get(tensor->buffer()); - vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[2], vec); -} - -tflchef::Operation *TFliteOpSpaceToBatchND::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("SpaceToBatchND"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SpaceToBatchND.h b/compiler/tflchef/tflite/src/Op/SpaceToBatchND.h deleted file mode 100644 index 9d7bc44e8..000000000 --- a/compiler/tflchef/tflite/src/Op/SpaceToBatchND.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SPACETOBATCHND_H__ -#define __TFLITE_OP_SPACETOBATCHND_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SpaceToBatchND - */ -class TFliteOpSpaceToBatchND : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SPACETOBATCHND_H__ diff --git a/compiler/tflchef/tflite/src/Op/SpaceToDepth.cpp b/compiler/tflchef/tflite/src/Op/SpaceToDepth.cpp deleted file mode 100644 index e5718b515..000000000 --- a/compiler/tflchef/tflite/src/Op/SpaceToDepth.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SpaceToDepth.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSpaceToDepth::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSpaceToDepth::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("SpaceToDepth"); - - auto op_params = op->builtin_options_as_SpaceToDepthOptions(); - assert(op_params != nullptr); - - auto op_options = operation->mutable_space_to_depth_options(); - - op_options->set_block_size(op_params->block_size()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SpaceToDepth.h b/compiler/tflchef/tflite/src/Op/SpaceToDepth.h deleted file mode 100644 index 784ad940a..000000000 --- a/compiler/tflchef/tflite/src/Op/SpaceToDepth.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SPACETODEPTH_H__ -#define __TFLITE_OP_SPACETODEPTH_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SpaceToDepth - */ -class TFliteOpSpaceToDepth : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SPACETODEPTH_H__ diff --git a/compiler/tflchef/tflite/src/Op/SparseToDense.cpp b/compiler/tflchef/tflite/src/Op/SparseToDense.cpp deleted file mode 100644 index 9e4f0a067..000000000 --- a/compiler/tflchef/tflite/src/Op/SparseToDense.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SparseToDense.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSparseToDense::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for Shape - const auto &inputs = *op->inputs(); - - const tflite::Tensor *output_shape_tensor = import->tensors()->Get(inputs[1]); - assert(output_shape_tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(output_shape_tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpSparseToDense::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_SparseToDenseOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("SparseToDense"); - - auto op_options = operation->mutable_sparse_to_dense_options(); - - op_options->set_validate_indices(op_params->validate_indices()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SparseToDense.h b/compiler/tflchef/tflite/src/Op/SparseToDense.h deleted file mode 100644 index 5ffe4789d..000000000 --- a/compiler/tflchef/tflite/src/Op/SparseToDense.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SPARSETODENSE_H__ -#define __TFLITE_OP_SPARSETODENSE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SparseToDense - */ -class TFliteOpSparseToDense : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SPARSETODENSE_H__ diff --git a/compiler/tflchef/tflite/src/Op/Split.cpp b/compiler/tflchef/tflite/src/Op/Split.cpp deleted file mode 100644 index 49f9aa2c6..000000000 --- a/compiler/tflchef/tflite/src/Op/Split.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Split.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSplit::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const auto &inputs = *op->inputs(); - - // for input split_dim - // NOTE unlike other Ops, Split input 0 is split_dim - const tflite::Tensor *tensor = import->tensors()->Get(inputs[0]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[0], vec); -} - -tflchef::Operation *TFliteOpSplit::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Split"); - - auto op_options = operation->mutable_split_options(); - - auto op_params = op->builtin_options_as_SplitOptions(); - assert(op_params != nullptr); - - op_options->set_num_splits(op_params->num_splits()); - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Split.h b/compiler/tflchef/tflite/src/Op/Split.h deleted file mode 100644 index af247a1b9..000000000 --- a/compiler/tflchef/tflite/src/Op/Split.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SPLIT_H__ -#define __TFLITE_OP_SPLIT_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SPLIT - */ -class TFliteOpSplit : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SPLIT_H__ diff --git a/compiler/tflchef/tflite/src/Op/SplitV.cpp b/compiler/tflchef/tflite/src/Op/SplitV.cpp deleted file mode 100644 index 18035e6f4..000000000 --- a/compiler/tflchef/tflite/src/Op/SplitV.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SplitV.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSplitV::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const auto &inputs = *op->inputs(); - - // for input "size_splits" and "split_dim" - for (int32_t idx = 1; idx <= 2; idx++) - { - const tflite::Tensor *tensor = import->tensors()->Get(inputs[idx]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[idx], vec); - } -} - -tflchef::Operation *TFliteOpSplitV::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("SplitV"); - - auto op_options = operation->mutable_split_v_options(); - - auto op_params = op->builtin_options_as_SplitVOptions(); - assert(op_params != nullptr); - - op_options->set_num_splits(op_params->num_splits()); - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SplitV.h b/compiler/tflchef/tflite/src/Op/SplitV.h deleted file mode 100644 index 3f715b5f9..000000000 --- a/compiler/tflchef/tflite/src/Op/SplitV.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SPLIT_V_H__ -#define __TFLITE_OP_SPLIT_V_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SPLIT_V - */ -class TFliteOpSplitV : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SPLIT_V_H__ diff --git a/compiler/tflchef/tflite/src/Op/Sqrt.cpp b/compiler/tflchef/tflite/src/Op/Sqrt.cpp index dd6bfcab0..5d967d66f 100644 --- a/compiler/tflchef/tflite/src/Op/Sqrt.cpp +++ b/compiler/tflchef/tflite/src/Op/Sqrt.cpp @@ -25,19 +25,6 @@ void TFliteOpSqrt::filler(const tflite::Operator *op, TFliteImport *import, tflchef::ModelRecipe *model_recipe) const { // Nothing to do with filler - // But input has filler for constant inputs - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[0]); - if (tensor->type() == tflite::TensorType::TensorType_FLOAT32) - { - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - if (buffer && buffer->data()) - { - auto vec = extract_buffer<float>(buffer); - import->set_tensor_filler(inputs[0], vec); - } - } } tflchef::Operation *TFliteOpSqrt::build(const tflite::Operator *op, TFliteImport *import, diff --git a/compiler/tflchef/tflite/src/Op/Square.cpp b/compiler/tflchef/tflite/src/Op/Square.cpp deleted file mode 100644 index d3803284a..000000000 --- a/compiler/tflchef/tflite/src/Op/Square.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Square.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSquare::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSquare::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Square"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Square.h b/compiler/tflchef/tflite/src/Op/Square.h deleted file mode 100644 index 9c008fe52..000000000 --- a/compiler/tflchef/tflite/src/Op/Square.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SQUARE_H__ -#define __TFLITE_OP_SQUARE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Square - */ -class TFliteOpSquare : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SQUARE_H__ diff --git a/compiler/tflchef/tflite/src/Op/SquaredDifference.cpp b/compiler/tflchef/tflite/src/Op/SquaredDifference.cpp deleted file mode 100644 index 1ee536e76..000000000 --- a/compiler/tflchef/tflite/src/Op/SquaredDifference.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "SquaredDifference.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSquaredDifference::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSquaredDifference::build(const tflite::Operator *op, - TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("SquaredDifference"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/SquaredDifference.h b/compiler/tflchef/tflite/src/Op/SquaredDifference.h deleted file mode 100644 index 58c2ed460..000000000 --- a/compiler/tflchef/tflite/src/Op/SquaredDifference.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SQUAREDDIFFERENCE_H__ -#define __TFLITE_OP_SQUAREDDIFFERENCE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for SquaredDifference - */ -class TFliteOpSquaredDifference : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SQUAREDDIFFERENCE_H__ diff --git a/compiler/tflchef/tflite/src/Op/Squeeze.cpp b/compiler/tflchef/tflite/src/Op/Squeeze.cpp deleted file mode 100644 index 7983fc62a..000000000 --- a/compiler/tflchef/tflite/src/Op/Squeeze.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Squeeze.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSqueeze::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpSqueeze::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_SqueezeOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Squeeze"); - - auto op_options = operation->mutable_squeeze_options(); - - std::vector<int32_t> squeeze_dims = as_index_vector(op_params->squeeze_dims()); - - for (auto dim : squeeze_dims) - { - op_options->add_squeeze_dim(dim); - } - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Squeeze.h b/compiler/tflchef/tflite/src/Op/Squeeze.h deleted file mode 100644 index b6c89f73d..000000000 --- a/compiler/tflchef/tflite/src/Op/Squeeze.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SQUEEZE_H__ -#define __TFLITE_OP_SQUEEZE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Squeeze - */ -class TFliteOpSqueeze : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SQUEEZE_H__ diff --git a/compiler/tflchef/tflite/src/Op/StridedSlice.cpp b/compiler/tflchef/tflite/src/Op/StridedSlice.cpp deleted file mode 100644 index c770236c7..000000000 --- a/compiler/tflchef/tflite/src/Op/StridedSlice.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "StridedSlice.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpStridedSlice::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - - // for begin, end and strides - for (int32_t index = 1; index <= 3; ++index) - { - const tflite::Tensor *tensor = import->tensors()->Get(inputs[index]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[index], vec); - } -} - -tflchef::Operation *TFliteOpStridedSlice::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_StridedSliceOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("StridedSlice"); - - auto op_options = operation->mutable_strided_slice_options(); - - op_options->set_begin_mask(op_params->begin_mask()); - op_options->set_end_mask(op_params->end_mask()); - op_options->set_ellipsis_mask(op_params->ellipsis_mask()); - op_options->set_new_axis_mask(op_params->new_axis_mask()); - op_options->set_shrink_axis_mask(op_params->shrink_axis_mask()); - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/StridedSlice.h b/compiler/tflchef/tflite/src/Op/StridedSlice.h deleted file mode 100644 index 98054b9b9..000000000 --- a/compiler/tflchef/tflite/src/Op/StridedSlice.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_STRIDEDSLICE_H__ -#define __TFLITE_OP_STRIDEDSLICE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for StridedSlice - */ -class TFliteOpStridedSlice : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_STRIDEDSLICE_H__ diff --git a/compiler/tflchef/tflite/src/Op/Sub.cpp b/compiler/tflchef/tflite/src/Op/Sub.cpp index 0a08bbfdf..db77fddf7 100644 --- a/compiler/tflchef/tflite/src/Op/Sub.cpp +++ b/compiler/tflchef/tflite/src/Op/Sub.cpp @@ -17,7 +17,6 @@ #include "Sub.h" #include "Convert.h" -#include "FillerHelper.h" namespace tflchef { @@ -25,13 +24,7 @@ namespace tflchef void TFliteOpSub::filler(const tflite::Operator *op, TFliteImport *import, tflchef::ModelRecipe *model_recipe) const { - // Sub may have constant input - - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - assert(inputs.size() == 2); - - fill_tensor_to_import(inputs[0], import); - fill_tensor_to_import(inputs[1], import); + // Nothing to do with filler } tflchef::Operation *TFliteOpSub::build(const tflite::Operator *op, TFliteImport *import, diff --git a/compiler/tflchef/tflite/src/Op/Sum.cpp b/compiler/tflchef/tflite/src/Op/Sum.cpp deleted file mode 100644 index 9f3133e85..000000000 --- a/compiler/tflchef/tflite/src/Op/Sum.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Sum.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpSum::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpSum::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_ReducerOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Sum"); - - auto op_options = operation->mutable_sum_options(); - - op_options->set_keep_dims(op_params->keep_dims()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Sum.h b/compiler/tflchef/tflite/src/Op/Sum.h deleted file mode 100644 index 38eeb080d..000000000 --- a/compiler/tflchef/tflite/src/Op/Sum.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_SUM_H__ -#define __TFLITE_OP_SUM_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for sum - */ -class TFliteOpSum : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_SUM_H__ diff --git a/compiler/tflchef/tflite/src/Op/Tanh.cpp b/compiler/tflchef/tflite/src/Op/Tanh.cpp deleted file mode 100644 index cab8ca460..000000000 --- a/compiler/tflchef/tflite/src/Op/Tanh.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Tanh.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpTanh::filler(const tflite::Operator *, TFliteImport *, tflchef::ModelRecipe *) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpTanh::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Tanh"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Tanh.h b/compiler/tflchef/tflite/src/Op/Tanh.h deleted file mode 100644 index 7339e4103..000000000 --- a/compiler/tflchef/tflite/src/Op/Tanh.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_TANH_H__ -#define __TFLITE_OP_TANH_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Tanh - */ -class TFliteOpTanh : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_TANH_H__ diff --git a/compiler/tflchef/tflite/src/Op/Tile.cpp b/compiler/tflchef/tflite/src/Op/Tile.cpp deleted file mode 100644 index 14e65131c..000000000 --- a/compiler/tflchef/tflite/src/Op/Tile.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Tile.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpTile::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32 || - tensor->type() == tflite::TensorType::TensorType_INT64); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpTile::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Tile"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Tile.h b/compiler/tflchef/tflite/src/Op/Tile.h deleted file mode 100644 index 640f52a1f..000000000 --- a/compiler/tflchef/tflite/src/Op/Tile.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_TILE_H__ -#define __TFLITE_OP_TILE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Tile - */ -class TFliteOpTile : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_TILE_H__ diff --git a/compiler/tflchef/tflite/src/Op/TopKV2.cpp b/compiler/tflchef/tflite/src/Op/TopKV2.cpp deleted file mode 100644 index 461456ae2..000000000 --- a/compiler/tflchef/tflite/src/Op/TopKV2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "TopKV2.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpTopKV2::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // filler for second input - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[1]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32 || - tensor->type() == tflite::TensorType::TensorType_INT64); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpTopKV2::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("TopKV2"); - - // NOTE there is `sorted` attribute in TF but it's always true for TFlite - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/TopKV2.h b/compiler/tflchef/tflite/src/Op/TopKV2.h deleted file mode 100644 index b2b74cc75..000000000 --- a/compiler/tflchef/tflite/src/Op/TopKV2.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_TOPK_V2_H__ -#define __TFLITE_OP_TOPK_V2_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for TOPK_V2 - */ -class TFliteOpTopKV2 : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_TOPK_V2_H__ diff --git a/compiler/tflchef/tflite/src/Op/Transpose.cpp b/compiler/tflchef/tflite/src/Op/Transpose.cpp deleted file mode 100644 index a997bb08e..000000000 --- a/compiler/tflchef/tflite/src/Op/Transpose.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Transpose.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpTranspose::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const auto &inputs = *op->inputs(); - - const tflite::Tensor *perm_tensor = import->tensors()->Get(inputs[1]); - assert(perm_tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(perm_tensor->buffer()); - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[1], vec); -} - -tflchef::Operation *TFliteOpTranspose::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Transpose"); - - // No options for Transpose - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Transpose.h b/compiler/tflchef/tflite/src/Op/Transpose.h deleted file mode 100644 index f0d944b6b..000000000 --- a/compiler/tflchef/tflite/src/Op/Transpose.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_TRANSPOSE_H__ -#define __TFLITE_OP_TRANSPOSE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Transpose - */ -class TFliteOpTranspose : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_TRANSPOSE_H__ diff --git a/compiler/tflchef/tflite/src/Op/TransposeConv.cpp b/compiler/tflchef/tflite/src/Op/TransposeConv.cpp deleted file mode 100644 index 4e7adf6c6..000000000 --- a/compiler/tflchef/tflite/src/Op/TransposeConv.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "TransposeConv.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpTransposeConv::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const auto &inputs = *op->inputs(); - - const tflite::Tensor *tensor = import->tensors()->Get(inputs[0]); - assert(tensor->type() == tflite::TensorType::TensorType_INT32); - const tflite::Buffer *buffer = import->buffers()->Get(tensor->buffer()); - - if (buffer && buffer->data()) - { - auto vec = extract_buffer<int32_t>(buffer); - import->set_tensor_filler(inputs[0], vec); - } - - // filter - const tflite::Tensor *filter_tensor = import->tensors()->Get(inputs[1]); - import->set_tensor_filler(inputs[1]); -} - -tflchef::Operation *TFliteOpTransposeConv::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_TransposeConvOptions(); - - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("TransposeConv"); - - auto op_options = operation->mutable_transpose_conv_options(); - - op_options->set_stride_h(op_params->stride_h()); - op_options->set_stride_w(op_params->stride_w()); - op_options->set_padding(as_tflchef_padding(op_params->padding())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/TransposeConv.h b/compiler/tflchef/tflite/src/Op/TransposeConv.h deleted file mode 100644 index c79cdabd2..000000000 --- a/compiler/tflchef/tflite/src/Op/TransposeConv.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_TRANSPOSE_CONV_H__ -#define __TFLITE_OP_TRANSPOSE_CONV_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for TransposeConv - */ -class TFliteOpTransposeConv : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_TRANSPOSE_CONV_H__ diff --git a/compiler/tflchef/tflite/src/Op/UnidirectionalSequenceLSTM.cpp b/compiler/tflchef/tflite/src/Op/UnidirectionalSequenceLSTM.cpp deleted file mode 100644 index c2c79285b..000000000 --- a/compiler/tflchef/tflite/src/Op/UnidirectionalSequenceLSTM.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "UnidirectionalSequenceLSTM.h" - -#include "Convert.h" -#include "FillerHelper.h" - -namespace tflchef -{ - -void TFliteOpUnidirectionalSequenceLSTM::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); - assert(inputs.size() == 24); - - for (int32_t i = 0; i < inputs.size(); i++) - { - // Except for Input 0, 17 and 18. - // Each Input mean Input[0](=Input Tensor), Input[17](=OutputState Tensor) and - // Input[18](=CellState Tensor). - // This could be updated from previous input or User Given data, so This could not be Const - if (i == 0 || i == 17 || i == 18) - continue; - if (inputs[i] != -1) - fill_tensor_to_import(inputs[i], import); - } -} - -tflchef::Operation * -TFliteOpUnidirectionalSequenceLSTM::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_UnidirectionalSequenceLSTMOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("UnidirectionalSequenceLSTM"); - - auto op_options = operation->mutable_unidirectional_sequence_lstm_options(); - - op_options->set_activation(as_tflchef_activation(op_params->fused_activation_function())); - op_options->set_cell_clip(op_params->cell_clip()); - op_options->set_proj_clip(op_params->proj_clip()); - op_options->set_time_major(op_params->time_major()); - op_options->set_asymmetric_quantize_inputs(op_params->asymmetric_quantize_inputs()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/UnidirectionalSequenceLSTM.h b/compiler/tflchef/tflite/src/Op/UnidirectionalSequenceLSTM.h deleted file mode 100644 index cc4e5fb0f..000000000 --- a/compiler/tflchef/tflite/src/Op/UnidirectionalSequenceLSTM.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_UNIDIRECTIONALSEQUENCELSTM_H__ -#define __TFLITE_OP_UNIDIRECTIONALSEQUENCELSTM_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for UnidirectionalSequenceLSTM - */ -class TFliteOpUnidirectionalSequenceLSTM : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_UNIDIRECTIONALSEQUENCELSTM_H__ diff --git a/compiler/tflchef/tflite/src/Op/Unique.cpp b/compiler/tflchef/tflite/src/Op/Unique.cpp deleted file mode 100644 index e3f77f40e..000000000 --- a/compiler/tflchef/tflite/src/Op/Unique.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Unique.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpUnique::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpUnique::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto op_params = op->builtin_options_as_UniqueOptions(); - assert(op_params != nullptr); - - auto operation = model_recipe->add_operation(); - - operation->set_type("Unique"); - - auto op_options = operation->mutable_unique_options(); - - op_options->set_idx_out_type(as_tflchef_type(op_params->idx_out_type())); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Unique.h b/compiler/tflchef/tflite/src/Op/Unique.h deleted file mode 100644 index fae037c9f..000000000 --- a/compiler/tflchef/tflite/src/Op/Unique.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_UNIQUE_H__ -#define __TFLITE_OP_UNIQUE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Unique - */ -class TFliteOpUnique : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_UNIQUE_H__ diff --git a/compiler/tflchef/tflite/src/Op/Unpack.cpp b/compiler/tflchef/tflite/src/Op/Unpack.cpp deleted file mode 100644 index a51ef84ef..000000000 --- a/compiler/tflchef/tflite/src/Op/Unpack.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Unpack.h" - -namespace tflchef -{ - -void TFliteOpUnpack::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with filler -} - -tflchef::Operation *TFliteOpUnpack::build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - - operation->set_type("Unpack"); - - auto op_params = op->builtin_options_as_UnpackOptions(); - assert(op_params != nullptr); - - auto op_options = operation->mutable_unpack_options(); - op_options->set_num(op_params->num()); - op_options->set_axis(op_params->axis()); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Unpack.h b/compiler/tflchef/tflite/src/Op/Unpack.h deleted file mode 100644 index 1036bdc14..000000000 --- a/compiler/tflchef/tflite/src/Op/Unpack.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_UNPACK_H__ -#define __TFLITE_OP_UNPACK_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Unpack - */ -class TFliteOpUnpack : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_UNPACK_H__ diff --git a/compiler/tflchef/tflite/src/Op/Where.cpp b/compiler/tflchef/tflite/src/Op/Where.cpp deleted file mode 100644 index e42de3737..000000000 --- a/compiler/tflchef/tflite/src/Op/Where.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "Where.h" - -namespace tflchef -{ - -void TFliteOpWhere::filler(const tflite::Operator *, TFliteImport *, tflchef::ModelRecipe *) const -{ - // Nothing to do with fillers here -} - -tflchef::Operation *TFliteOpWhere::build(const tflite::Operator *, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("Where"); - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/Where.h b/compiler/tflchef/tflite/src/Op/Where.h deleted file mode 100644 index 00cdc4b00..000000000 --- a/compiler/tflchef/tflite/src/Op/Where.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_WHERE_H__ -#define __TFLITE_OP_WHERE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for Where - */ -class TFliteOpWhere : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_WHERE_H__ diff --git a/compiler/tflchef/tflite/src/Op/ZerosLike.cpp b/compiler/tflchef/tflite/src/Op/ZerosLike.cpp deleted file mode 100644 index a56b6bdfb..000000000 --- a/compiler/tflchef/tflite/src/Op/ZerosLike.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 "ZerosLike.h" - -#include "Convert.h" - -namespace tflchef -{ - -void TFliteOpZerosLike::filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const -{ - // Nothing to do with fillers here -} - -tflchef::Operation *TFliteOpZerosLike::build(const tflite::Operator *op, TFliteImport *, - tflchef::ModelRecipe *model_recipe) const -{ - auto operation = model_recipe->add_operation(); - operation->set_type("ZerosLike"); - - auto op_options = operation->mutable_zeros_like_options(); - (void)op_options; - - return operation; -} - -} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/Op/ZerosLike.h b/compiler/tflchef/tflite/src/Op/ZerosLike.h deleted file mode 100644 index 163c1fa21..000000000 --- a/compiler/tflchef/tflite/src/Op/ZerosLike.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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 __TFLITE_OP_ZEROS_LIKE_H__ -#define __TFLITE_OP_ZEROS_LIKE_H__ - -#include "TFliteOpChef.h" - -namespace tflchef -{ - -/** - * @brief tflchef operator builder for ZerosLike - */ -class TFliteOpZerosLike : public TFliteOpChef -{ -public: - void filler(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; - tflchef::Operation *build(const tflite::Operator *op, TFliteImport *import, - tflchef::ModelRecipe *model_recipe) const override; -}; - -} // namespace tflchef - -#endif // __TFLITE_OP_ZEROS_LIKE_H__ diff --git a/compiler/tflchef/tflite/src/RawModelLoader.cpp b/compiler/tflchef/tflite/src/RawModelLoader.cpp new file mode 100644 index 000000000..e9ef8ec8b --- /dev/null +++ b/compiler/tflchef/tflite/src/RawModelLoader.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 <tflchef/RawModel.h> + +#include <cwrap/Fildes.h> + +#include <fcntl.h> +#include <unistd.h> +#include <sys/stat.h> +#include <sys/mman.h> + +namespace +{ + +class MemoryMappedRawModel final : public tflchef::RawModel +{ +public: + /** + * @require fd and data SHOULD be valid + */ + explicit MemoryMappedRawModel(int fd, void *data, size_t size) : _fd{fd}, _data{data}, _size{size} + { + // DO NOTHING + } + +public: + ~MemoryMappedRawModel() + { + munmap(_data, _size); + close(_fd); + } + +public: + MemoryMappedRawModel(const MemoryMappedRawModel &) = delete; + MemoryMappedRawModel(MemoryMappedRawModel &&) = delete; + +public: + const ::tflite::Model *model(void) const override { return ::tflite::GetModel(_data); } + +private: + int _fd = -1; + void *_data = nullptr; + size_t _size = 0; +}; + +} // namespace + +namespace tflchef +{ + +std::unique_ptr<RawModel> load_tflite(const std::string &path) +{ + cwrap::Fildes fildes{open(path.c_str(), O_RDONLY)}; + + if (fildes.get() == -1) + { + // Return nullptr on open failure + return nullptr; + } + + struct stat st; + if (fstat(fildes.get(), &st) == -1) + { + // Return nullptr on fstat failure + return nullptr; + } + + auto size = st.st_size; + auto data = mmap(nullptr, size, PROT_READ, MAP_SHARED, fildes.get(), 0); + + if (data == MAP_FAILED) + { + // Return nullptr on mmap failure + return nullptr; + } + + return std::unique_ptr<tflchef::RawModel>{new MemoryMappedRawModel(fildes.release(), data, size)}; +} + +} // namespace tflchef diff --git a/compiler/tflchef/tflite/src/RecipeChef.cpp b/compiler/tflchef/tflite/src/RecipeChef.cpp index 32ac9c3f3..0a26ae066 100644 --- a/compiler/tflchef/tflite/src/RecipeChef.cpp +++ b/compiler/tflchef/tflite/src/RecipeChef.cpp @@ -35,16 +35,9 @@ void set_inputs(TFliteImport *import, tflchef::Operation *operation, const tflit for (auto input : inputs) { - if (input == -1) - { - operation->add_input(""); - } - else - { - auto tensor = tensors->Get(input); - std::string name = tensor_name(tensor); - operation->add_input(name); - } + auto tensor = tensors->Get(input); + std::string name = tensor_name(tensor); + operation->add_input(name); } } @@ -110,21 +103,16 @@ std::unique_ptr<ModelRecipe> generate_recipe(const tflite::Model *model) operand->set_name(tensor_name(tensor)); operand->set_type(as_tflchef_type(tensor->type())); - operand->set_is_variable(tensor->is_variable()); - if (tensor->shape()) + std::vector<int32_t> dims = as_index_vector(tensor->shape()); + ::tflchef::TensorShape *shape = operand->mutable_shape(); + for (auto dim : dims) { - std::vector<int32_t> dims = as_index_vector(tensor->shape()); - ::tflchef::TensorShape *shape = operand->mutable_shape(); - for (auto dim : dims) - { - shape->add_dim(dim); - } + shape->add_dim(dim); } // filler for weights, bias and so on std::vector<int32_t> expvalues; - std::vector<float> expfvalues; if (tflite_import.get_tensor_filler(i)) { tflchef::TensorFiller *filler = operand->mutable_filler(); @@ -144,17 +132,6 @@ std::unique_ptr<ModelRecipe> generate_recipe(const tflite::Model *model) filler->add_arg(ss.str()); } } - else if (tflite_import.get_tensor_filler(i, expfvalues)) - { - tflchef::TensorFiller *filler = operand->mutable_filler(); - filler->set_tag("explicit"); - for (auto value : expfvalues) - { - std::ostringstream ss; - ss << value; - filler->add_arg(ss.str()); - } - } auto quant = tensor->quantization(); if (quant != nullptr) @@ -185,91 +162,6 @@ std::unique_ptr<ModelRecipe> generate_recipe(const tflite::Model *model) for (uint32_t idx = 0; idx < quant->zero_point()->size(); ++idx) chef_quant->add_zero_point(quant->zero_point()->Get(idx)); } - tflchef::TensorQuantization *chef_quant = operand->mutable_quant(); - chef_quant->set_quantized_dimension(quant->quantized_dimension()); - } - - auto sparsity = tensor->sparsity(); - if (sparsity != nullptr) - { - tflchef::TensorSparsity *chef_sparsity = operand->mutable_sparsity(); - // traversal_order - auto chef_traversal_order = chef_sparsity->mutable_traversal_order(); - for (const auto &to : *(sparsity->traversal_order())) - { - chef_traversal_order->add_dim(to); - } - // block_map - auto chef_block_map = chef_sparsity->mutable_block_map(); - for (const auto &bm : *(sparsity->block_map())) - { - chef_block_map->add_dim(bm); - } - // dim_metadata - for (const auto &dm : *(sparsity->dim_metadata())) - { - auto chef_dm = chef_sparsity->add_dim_metadata(); - // format - chef_dm->set_format(as_tflchef_sparse_dim_type(dm->format())); - // dense_size - chef_dm->set_dense_size(dm->dense_size()); - // array_segments - auto chef_array_segments = chef_dm->mutable_array_segments(); - switch (dm->array_segments_type()) - { - case tflite::SparseIndexVector_NONE: - // DO NOTHING - break; - case tflite::SparseIndexVector_Int32Vector: - for (const auto &as : *(dm->array_segments_as_Int32Vector()->values())) - { - chef_array_segments->add_dim(as); - } - break; - case tflite::SparseIndexVector_Uint16Vector: - for (const auto &as : *(dm->array_segments_as_Uint16Vector()->values())) - { - chef_array_segments->add_dim(as); - } - break; - case tflite::SparseIndexVector_Uint8Vector: - for (const auto &as : *(dm->array_segments_as_Uint8Vector()->values())) - { - chef_array_segments->add_dim(as); - } - break; - default: - throw std::runtime_error("unsupported sparse index vector type"); - } - // array_indices - auto chef_array_indices = chef_dm->mutable_array_indices(); - switch (dm->array_indices_type()) - { - case tflite::SparseIndexVector_NONE: - // DO NOTHING - break; - case tflite::SparseIndexVector_Int32Vector: - for (const auto &as : *(dm->array_indices_as_Int32Vector()->values())) - { - chef_array_indices->add_dim(as); - } - break; - case tflite::SparseIndexVector_Uint16Vector: - for (const auto &as : *(dm->array_indices_as_Uint16Vector()->values())) - { - chef_array_indices->add_dim(as); - } - break; - case tflite::SparseIndexVector_Uint8Vector: - for (const auto &as : *(dm->array_indices_as_Uint8Vector()->values())) - { - chef_array_indices->add_dim(as); - } - break; - default: - throw std::runtime_error("unsupported sparse index vector type"); - } - } } } diff --git a/compiler/tflchef/tflite/src/TFliteImport.h b/compiler/tflchef/tflite/src/TFliteImport.h index 9d0a642ab..ade8fc810 100644 --- a/compiler/tflchef/tflite/src/TFliteImport.h +++ b/compiler/tflchef/tflite/src/TFliteImport.h @@ -17,9 +17,7 @@ #ifndef __TFLITE_IMPORT_H__ #define __TFLITE_IMPORT_H__ -#include <mio/tflite/schema_generated.h> - -#include <souschef/TensorFiller.h> +#include <tflite_generated.h> #include <tflchef.pb.h> @@ -42,7 +40,7 @@ bool is_custom(const tflite::OperatorCode *opcode); /** * @brief Loads TF lite file and provides helpers to access attributes */ -class TFliteImport : public souschef::TensorFiller +class TFliteImport { public: TFliteImport(const tflite::Model *model); @@ -65,15 +63,59 @@ public: std::string opcode_name(const tflite::Operator *op) const; size_t buffer_info(const tflite::Tensor *tensor, const uint8_t **buff_data); + /** + * @brief This will record the tensor by index, if it needs filler option, + * such as kernel, bias. + */ + void set_tensor_filler(uint32_t tensor_index) { _tensor_filler[tensor_index] = true; } + + /** + * @brief This will store int32 filler values such as reshape information for the tensor + */ + void set_tensor_filler(uint32_t tensor_index, std::vector<int32_t> &expvalues) + { + _tensor_filler_vint32[tensor_index] = expvalues; + } + + /** + * @brief This will return true if the tensor by index, needs a filler option. + */ + bool get_tensor_filler(uint32_t tensor_index) + { + auto it = _tensor_filler.find(tensor_index); + if (it != _tensor_filler.end()) + { + return it->second; + } + return false; + } + + /** + * @brief This will return true if the tensor by index, needs a int array filler option. + */ + bool get_tensor_filler(uint32_t tensor_index, std::vector<int32_t> &expvalues) + { + auto it = _tensor_filler_vint32.find(tensor_index); + if (it != _tensor_filler_vint32.end()) + { + expvalues = it->second; + return true; + } + return false; + } + private: - const TFliteSubGraphs_t *_subgraphs{nullptr}; - const TFliteBuffers_t *_buffers{nullptr}; - const TFliteTensors_t *_tensors{nullptr}; - const TFliteOperators_t *_operators{nullptr}; - - std::vector<const tflite::OperatorCode *> _op_codes{}; - std::vector<int32_t> _inputs{}; - std::vector<int32_t> _outputs{}; + const TFliteSubGraphs_t *_subgraphs; + const TFliteBuffers_t *_buffers; + const TFliteTensors_t *_tensors; + const TFliteOperators_t *_operators; + + std::vector<const tflite::OperatorCode *> _op_codes; + std::vector<int32_t> _inputs; + std::vector<int32_t> _outputs; + + std::map<uint32_t, bool> _tensor_filler; + std::map<uint32_t, std::vector<int32_t>> _tensor_filler_vint32; }; } // namespace tflchef diff --git a/compiler/tflchef/tflite/src/TFliteOpChef.h b/compiler/tflchef/tflite/src/TFliteOpChef.h index 98564293b..fc9047ce7 100644 --- a/compiler/tflchef/tflite/src/TFliteOpChef.h +++ b/compiler/tflchef/tflite/src/TFliteOpChef.h @@ -17,7 +17,7 @@ #ifndef __TFLITE_OP_CHEF_H__ #define __TFLITE_OP_CHEF_H__ -#include <mio/tflite/schema_generated.h> +#include <tflite_generated.h> #include <tflchef.pb.h> diff --git a/compiler/tflchef/tflite/src/TFliteOpChefs.h b/compiler/tflchef/tflite/src/TFliteOpChefs.h index 2e4d28051..9f3446840 100644 --- a/compiler/tflchef/tflite/src/TFliteOpChefs.h +++ b/compiler/tflchef/tflite/src/TFliteOpChefs.h @@ -18,111 +18,17 @@ #define __TFLITE_OP_CHEFS_H__ // In alphabet order -#include "Op/Abs.h" -#include "Op/Add.h" -#include "Op/AddN.h" -#include "Op/ArgMax.h" -#include "Op/ArgMin.h" #include "Op/AveragePool2D.h" -#include "Op/BatchMatMul.h" -#include "Op/BatchToSpaceND.h" -#include "Op/Cast.h" -#include "Op/Ceil.h" #include "Op/Concatenation.h" #include "Op/Conv2D.h" -#include "Op/Cos.h" -#include "Op/DepthToSpace.h" #include "Op/DepthwiseConv2D.h" -#include "Op/Dequantize.h" #include "Op/Div.h" -#include "Op/ELU.h" -#include "Op/Equal.h" -#include "Op/Exp.h" -#include "Op/ExpandDims.h" -#include "Op/Fill.h" -#include "Op/Floor.h" -#include "Op/FloorDiv.h" -#include "Op/FloorMod.h" #include "Op/FullyConnected.h" -#include "Op/Gather.h" -#include "Op/GatherNd.h" -#include "Op/Greater.h" -#include "Op/GreaterEqual.h" -#include "Op/L2Normalize.h" -#include "Op/L2Pool2D.h" -#include "Op/LeakyRelu.h" -#include "Op/Less.h" -#include "Op/LessEqual.h" -#include "Op/LocalResponseNormalization.h" -#include "Op/Log.h" -#include "Op/LogicalAnd.h" -#include "Op/LogicalNot.h" -#include "Op/LogicalOr.h" -#include "Op/Logistic.h" -#include "Op/LogSoftmax.h" -#include "Op/MatrixDiag.h" -#include "Op/MatrixSetDiag.h" -#include "Op/Maximum.h" #include "Op/MaxPool2D.h" -#include "Op/Mean.h" -#include "Op/Minimum.h" -#include "Op/MirrorPad.h" -#include "Op/Mul.h" -#include "Op/Neg.h" -#include "Op/NonMaxSuppressionV4.h" -#include "Op/NonMaxSuppressionV5.h" -#include "Op/NotEqual.h" -#include "Op/OneHot.h" -#include "Op/Pack.h" -#include "Op/Pad.h" -#include "Op/PadV2.h" -#include "Op/Pow.h" -#include "Op/PRelu.h" -#include "Op/Range.h" -#include "Op/Rank.h" -#include "Op/ReduceAny.h" -#include "Op/ReduceMax.h" -#include "Op/ReduceMin.h" -#include "Op/ReduceProd.h" #include "Op/ReLU.h" #include "Op/ReLU6.h" -#include "Op/ReLUN1To1.h" #include "Op/Reshape.h" -#include "Op/ResizeBilinear.h" -#include "Op/ResizeNearestNeighbor.h" -#include "Op/ReverseSequence.h" -#include "Op/ReverseV2.h" -#include "Op/Round.h" -#include "Op/Rsqrt.h" -#include "Op/ScatterNd.h" -#include "Op/SegmentSum.h" -#include "Op/Select.h" -#include "Op/SelectV2.h" -#include "Op/Shape.h" -#include "Op/Sin.h" -#include "Op/Slice.h" -#include "Op/Softmax.h" -#include "Op/SpaceToBatchND.h" -#include "Op/SpaceToDepth.h" -#include "Op/SparseToDense.h" -#include "Op/Split.h" -#include "Op/SplitV.h" #include "Op/Sqrt.h" -#include "Op/Square.h" -#include "Op/SquaredDifference.h" -#include "Op/Squeeze.h" -#include "Op/StridedSlice.h" #include "Op/Sub.h" -#include "Op/Sum.h" -#include "Op/Tanh.h" -#include "Op/Tile.h" -#include "Op/TopKV2.h" -#include "Op/Transpose.h" -#include "Op/TransposeConv.h" -#include "Op/UnidirectionalSequenceLSTM.h" -#include "Op/Unique.h" -#include "Op/Unpack.h" -#include "Op/Where.h" -#include "Op/ZerosLike.h" #endif // __TFLITE_OP_CHEFS_H__ diff --git a/compiler/tflchef/tflite/src/TFliteOpRegistry.h b/compiler/tflchef/tflite/src/TFliteOpRegistry.h index 9cc630a97..9e085028c 100644 --- a/compiler/tflchef/tflite/src/TFliteOpRegistry.h +++ b/compiler/tflchef/tflite/src/TFliteOpRegistry.h @@ -20,7 +20,9 @@ #include "TFliteOpChef.h" #include "TFliteOpChefs.h" -#include <memory> +#include <stdex/Memory.h> + +using stdex::make_unique; namespace tflchef { @@ -52,117 +54,19 @@ public: private: TFliteOpRegistry() { -#define REG_TFL_OP(OPCODE, CLASS) \ - _tfliteop_map[tflite::BuiltinOperator_##OPCODE] = std::make_unique<CLASS>() - - REG_TFL_OP(ABS, TFliteOpAbs); - REG_TFL_OP(ADD, TFliteOpAdd); - REG_TFL_OP(ADD_N, TFliteOpAddN); - REG_TFL_OP(ARG_MAX, TFliteOpArgMax); - REG_TFL_OP(ARG_MIN, TFliteOpArgMin); - REG_TFL_OP(AVERAGE_POOL_2D, TFliteOpAveragePool2D); - REG_TFL_OP(BATCH_MATMUL, TFliteOpBatchMatMul); - REG_TFL_OP(BATCH_TO_SPACE_ND, TFliteOpBatchToSpaceND); - REG_TFL_OP(CAST, TFliteOpCast); - REG_TFL_OP(CEIL, TFliteOpCeil); - REG_TFL_OP(CONCATENATION, TFliteOpConcatenation); - REG_TFL_OP(CONV_2D, TFliteOpConv2D); - REG_TFL_OP(COS, TFliteOpCos); - REG_TFL_OP(DEPTH_TO_SPACE, TFliteOpDepthToSpace); - REG_TFL_OP(DEPTHWISE_CONV_2D, TFliteOpDepthwiseConv2D); - REG_TFL_OP(DEQUANTIZE, TFliteOpDequantize); - REG_TFL_OP(DIV, TFliteOpDiv); - REG_TFL_OP(ELU, TFliteOpELU); - REG_TFL_OP(EQUAL, TFliteOpEqual); - REG_TFL_OP(EXP, TFliteOpExp); - REG_TFL_OP(EXPAND_DIMS, TFliteOpExpandDims); - REG_TFL_OP(FILL, TFliteOpFill); - REG_TFL_OP(FLOOR, TFliteOpFloor); - REG_TFL_OP(FLOOR_DIV, TFliteOpFloorDiv); - REG_TFL_OP(FLOOR_MOD, TFliteOpFloorMod); - REG_TFL_OP(FULLY_CONNECTED, TFliteOpFullyConnected); - REG_TFL_OP(GATHER, TFliteOpGather); - REG_TFL_OP(GATHER_ND, TFliteOpGatherNd); - REG_TFL_OP(GREATER, TFliteOpGreater); - REG_TFL_OP(GREATER_EQUAL, TFliteOpGreaterEqual); - REG_TFL_OP(L2_NORMALIZATION, TFliteOpL2Normalize); - REG_TFL_OP(L2_POOL_2D, TFliteOpL2Pool2D); - REG_TFL_OP(LEAKY_RELU, TFliteOpLeakyRelu); - REG_TFL_OP(LESS, TFliteOpLess); - REG_TFL_OP(LESS_EQUAL, TFliteOpLessEqual); - REG_TFL_OP(LOCAL_RESPONSE_NORMALIZATION, TFliteOpLocalResponseNormalization); - REG_TFL_OP(LOG, TFliteOpLog); - REG_TFL_OP(LOGICAL_AND, TFliteOpLogicalAnd); - REG_TFL_OP(LOGICAL_NOT, TFliteOpLogicalNot); - REG_TFL_OP(LOGICAL_OR, TFliteOpLogicalOr); - REG_TFL_OP(LOGISTIC, TFliteOpLogistic); - REG_TFL_OP(LOG_SOFTMAX, TFliteOpLogSoftmax); - REG_TFL_OP(MATRIX_DIAG, TFliteOpMatrixDiag); - REG_TFL_OP(MAX_POOL_2D, TFliteOpMaxPool2D); - REG_TFL_OP(MATRIX_SET_DIAG, TFliteOpMatrixSetDiag); - REG_TFL_OP(MAXIMUM, TFliteOpMaximum); - REG_TFL_OP(MEAN, TFliteOpMean); - REG_TFL_OP(MINIMUM, TFliteOpMinimum); - REG_TFL_OP(MIRROR_PAD, TFliteOpMirrorPad); - REG_TFL_OP(MUL, TFliteOpMul); - REG_TFL_OP(NEG, TFliteOpNeg); - REG_TFL_OP(NON_MAX_SUPPRESSION_V4, TFliteOpNonMaxSuppressionV4); - REG_TFL_OP(NON_MAX_SUPPRESSION_V5, TFliteOpNonMaxSuppressionV5); - REG_TFL_OP(NOT_EQUAL, TFliteOpNotEqual); - REG_TFL_OP(ONE_HOT, TFliteOpOneHot); - REG_TFL_OP(PACK, TFliteOpPack); - REG_TFL_OP(PAD, TFliteOpPad); - REG_TFL_OP(PADV2, TFliteOpPadV2); - REG_TFL_OP(POW, TFliteOpPow); - REG_TFL_OP(PRELU, TFliteOpPRelu); - REG_TFL_OP(RANGE, TFliteOpRange); - REG_TFL_OP(RANK, TFliteOpRank); - REG_TFL_OP(REDUCE_ANY, TFliteOpReduceAny); - REG_TFL_OP(REDUCE_MAX, TFliteOpReduceMax); - REG_TFL_OP(REDUCE_MIN, TFliteOpReduceMin); - REG_TFL_OP(REDUCE_PROD, TFliteOpReduceProd); - REG_TFL_OP(RELU, TFliteOpReLU); - REG_TFL_OP(RELU6, TFliteOpReLU6); - REG_TFL_OP(RELU_N1_TO_1, TFliteOpReLUN1To1); - REG_TFL_OP(RESHAPE, TFliteOpReshape); - REG_TFL_OP(RESIZE_BILINEAR, TFliteOpResizeBilinear); - REG_TFL_OP(RESIZE_NEAREST_NEIGHBOR, TFliteOpResizeNearestNeighbor); - REG_TFL_OP(REVERSE_SEQUENCE, TFliteOpReverseSequence); - REG_TFL_OP(REVERSE_V2, TFliteOpReverseV2); - REG_TFL_OP(ROUND, TFliteOpRound); - REG_TFL_OP(RSQRT, TFliteOpRsqrt); - REG_TFL_OP(SCATTER_ND, TFliteOpScatterNd); - REG_TFL_OP(SEGMENT_SUM, TFliteOpSegmentSum); - REG_TFL_OP(SELECT, TFliteOpSelect); - REG_TFL_OP(SELECT_V2, TFliteOpSelectV2); - REG_TFL_OP(SHAPE, TFliteOpShape); - REG_TFL_OP(SIN, TFliteOpSin); - REG_TFL_OP(SLICE, TFliteOpSlice); - REG_TFL_OP(SOFTMAX, TFliteOpSoftmax); - REG_TFL_OP(SPACE_TO_BATCH_ND, TFliteOpSpaceToBatchND); - REG_TFL_OP(SPACE_TO_DEPTH, TFliteOpSpaceToDepth); - REG_TFL_OP(SPARSE_TO_DENSE, TFliteOpSparseToDense); - REG_TFL_OP(SPLIT, TFliteOpSplit); - REG_TFL_OP(SPLIT_V, TFliteOpSplitV); - REG_TFL_OP(SQRT, TFliteOpSqrt); - REG_TFL_OP(SQUARE, TFliteOpSquare); - REG_TFL_OP(SQUARED_DIFFERENCE, TFliteOpSquaredDifference); - REG_TFL_OP(SQUEEZE, TFliteOpSqueeze); - REG_TFL_OP(STRIDED_SLICE, TFliteOpStridedSlice); - REG_TFL_OP(SUB, TFliteOpSub); - REG_TFL_OP(SUM, TFliteOpSum); - REG_TFL_OP(TANH, TFliteOpTanh); - REG_TFL_OP(TILE, TFliteOpTile); - REG_TFL_OP(TOPK_V2, TFliteOpTopKV2); - REG_TFL_OP(TRANSPOSE, TFliteOpTranspose); - REG_TFL_OP(TRANSPOSE_CONV, TFliteOpTransposeConv); - REG_TFL_OP(UNIDIRECTIONAL_SEQUENCE_LSTM, TFliteOpUnidirectionalSequenceLSTM); - REG_TFL_OP(UNIQUE, TFliteOpUnique); - REG_TFL_OP(UNPACK, TFliteOpUnpack); - REG_TFL_OP(WHERE, TFliteOpWhere); - REG_TFL_OP(ZEROS_LIKE, TFliteOpZerosLike); - -#undef REG_TFL_OP + _tfliteop_map[tflite::BuiltinOperator_AVERAGE_POOL_2D] = make_unique<TFliteOpAveragePool2D>(); + _tfliteop_map[tflite::BuiltinOperator_CONCATENATION] = make_unique<TFliteOpConcatenation>(); + _tfliteop_map[tflite::BuiltinOperator_CONV_2D] = make_unique<TFliteOpConv2D>(); + _tfliteop_map[tflite::BuiltinOperator_DEPTHWISE_CONV_2D] = + make_unique<TFliteOpDepthwiseConv2D>(); + _tfliteop_map[tflite::BuiltinOperator_DIV] = make_unique<TFliteOpDiv>(); + _tfliteop_map[tflite::BuiltinOperator_FULLY_CONNECTED] = make_unique<TFliteOpFullyConnected>(); + _tfliteop_map[tflite::BuiltinOperator_MAX_POOL_2D] = make_unique<TFliteOpMaxPool2D>(); + _tfliteop_map[tflite::BuiltinOperator_RELU] = make_unique<TFliteOpReLU>(); + _tfliteop_map[tflite::BuiltinOperator_RELU6] = make_unique<TFliteOpReLU6>(); + _tfliteop_map[tflite::BuiltinOperator_RESHAPE] = make_unique<TFliteOpReshape>(); + _tfliteop_map[tflite::BuiltinOperator_SQRT] = make_unique<TFliteOpSqrt>(); + _tfliteop_map[tflite::BuiltinOperator_SUB] = make_unique<TFliteOpSub>(); } private: diff --git a/compiler/tflchef/tools/console/Driver.cpp b/compiler/tflchef/tools/console/Driver.cpp index d6f7ba1ae..0f319c0cd 100644 --- a/compiler/tflchef/tools/console/Driver.cpp +++ b/compiler/tflchef/tools/console/Driver.cpp @@ -24,8 +24,6 @@ int entry(int argc, char **argv) { - int32_t model_version = 1; - ::tflchef::ModelRecipe model_recipe; // Read a model recipe from standard input @@ -33,20 +31,9 @@ int entry(int argc, char **argv) google::protobuf::io::IstreamInputStream iis{&std::cin}; if (!google::protobuf::TextFormat::Parse(&iis, &model_recipe)) { - std::cerr << "ERROR: Failed to parse recipe" << std::endl; + std::cerr << "ERROR: Failed to parse recipe '" << argv[1] << "'" << std::endl; return 255; } - - if (model_recipe.has_version()) - { - model_version = model_recipe.version(); - } - } - - if (model_version > 1) - { - std::cerr << "ERROR: Unsupported recipe version: " << model_version << std::endl; - return 255; } auto generated_model = tflchef::cook(model_recipe); diff --git a/compiler/tflchef/tools/file/CMakeLists.txt b/compiler/tflchef/tools/file/CMakeLists.txt index f411d60f1..477b7d974 100644 --- a/compiler/tflchef/tools/file/CMakeLists.txt +++ b/compiler/tflchef/tools/file/CMakeLists.txt @@ -1,4 +1,3 @@ add_executable(tflchef-file Driver.cpp) -target_link_libraries(tflchef-file arser) target_link_libraries(tflchef-file tflchef_core) target_link_libraries(tflchef-file safemain) diff --git a/compiler/tflchef/tools/file/Driver.cpp b/compiler/tflchef/tools/file/Driver.cpp index 46e5b5583..1287b0104 100644 --- a/compiler/tflchef/tools/file/Driver.cpp +++ b/compiler/tflchef/tools/file/Driver.cpp @@ -20,64 +20,37 @@ #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/text_format.h> -#include <arser/arser.h> - #include <fstream> #include <iostream> int entry(int argc, char **argv) { - arser::Arser arser; - arser.add_argument("recipe") - .type(arser::DataType::STR) - .help("Source recipe file path to convert"); - arser.add_argument("tflite").type(arser::DataType::STR).help("Target tflite file path"); - - try - { - arser.parse(argc, argv); - } - catch (const std::runtime_error &err) + if (argc != 3) { - std::cout << err.what() << std::endl; - std::cout << arser; + std::cerr << "ERROR: Failed to parse arguments" << std::endl; + std::cerr << std::endl; + std::cerr << "USAGE: " << argv[0] << " [recipe] [output]" << std::endl; return 255; } - int32_t model_version = 1; - ::tflchef::ModelRecipe model_recipe; - std::string recipe_path = arser.get<std::string>("recipe"); // Load model recipe from a file { - std::ifstream is{recipe_path}; + std::ifstream is{argv[1]}; google::protobuf::io::IstreamInputStream iis{&is}; if (!google::protobuf::TextFormat::Parse(&iis, &model_recipe)) { - std::cerr << "ERROR: Failed to parse recipe '" << recipe_path << "'" << std::endl; + std::cerr << "ERROR: Failed to parse recipe '" << argv[1] << "'" << std::endl; return 255; } - - if (model_recipe.has_version()) - { - model_version = model_recipe.version(); - } - } - - if (model_version > 1) - { - std::cerr << "ERROR: Unsupported recipe version: " << model_version << ", '" << argv[1] << "'" - << std::endl; - return 255; } auto generated_model = tflchef::cook(model_recipe); - std::string tflite_path = arser.get<std::string>("tflite"); // Dump generated model into a file { - std::ofstream os{tflite_path, std::ios::binary}; + std::ofstream os{argv[2], std::ios::binary}; os.write(generated_model.base(), generated_model.size()); } diff --git a/compiler/tflchef/tools/reverse/CMakeLists.txt b/compiler/tflchef/tools/reverse/CMakeLists.txt index a5c0f5bca..63cb36c06 100644 --- a/compiler/tflchef/tools/reverse/CMakeLists.txt +++ b/compiler/tflchef/tools/reverse/CMakeLists.txt @@ -1,5 +1,3 @@ add_executable(tflchef-reverse Driver.cpp) -target_link_libraries(tflchef-reverse arser) target_link_libraries(tflchef-reverse tflchef_tflite) target_link_libraries(tflchef-reverse safemain) -target_link_libraries(tflchef-reverse foder) diff --git a/compiler/tflchef/tools/reverse/Driver.cpp b/compiler/tflchef/tools/reverse/Driver.cpp index 4d795a3d0..549756463 100644 --- a/compiler/tflchef/tools/reverse/Driver.cpp +++ b/compiler/tflchef/tools/reverse/Driver.cpp @@ -14,41 +14,34 @@ * limitations under the License. */ +#include <tflchef/RawModel.h> #include <tflchef/RecipeChef.h> -#include <arser/arser.h> -#include <foder/FileLoader.h> - #include <memory> #include <iostream> int entry(int argc, char **argv) { - arser::Arser arser; - arser.add_argument("tflite") - .type(arser::DataType::STR) - .help("Source tflite file path to convert"); - arser.add_argument("recipe").type(arser::DataType::STR).help("Target recipe file path"); - - try + if (argc != 3) { - arser.parse(argc, argv); + std::cerr << "ERROR: Failed to parse arguments" << std::endl; + std::cerr << std::endl; + std::cerr << "USAGE: " << argv[0] << " [tflite] [output]" << std::endl; + return 255; } - catch (const std::runtime_error &err) + + // Load TF lite model from a tflite file + std::unique_ptr<tflchef::RawModel> rawmodel = tflchef::load_tflite(argv[1]); + if (rawmodel == nullptr) { - std::cout << err.what() << std::endl; - std::cout << arser; + std::cerr << "ERROR: Failed to load tflite '" << argv[1] << "'" << std::endl; return 255; } - std::string tflite_path = arser.get<std::string>("tflite"); - // Load TF lite model from a tflite file - const foder::FileLoader fileLoader{tflite_path}; - std::vector<char> modelData = fileLoader.load(); - const tflite::Model *tflmodel = tflite::GetModel(modelData.data()); + const tflite::Model *tflmodel = rawmodel->model(); if (tflmodel == nullptr) { - std::cerr << "ERROR: Failed to load tflite '" << tflite_path << "'" << std::endl; + std::cerr << "ERROR: Failed to load tflite '" << argv[1] << "'" << std::endl; return 255; } @@ -60,12 +53,11 @@ int entry(int argc, char **argv) return 255; } - std::string recipe_path = arser.get<std::string>("recipe"); // Save to a file - bool result = tflchef::write_recipe(recipe_path, recipe); + bool result = tflchef::write_recipe(argv[2], recipe); if (!result) { - std::cerr << "ERROR: Failed to write to recipe '" << recipe_path << "'" << std::endl; + std::cerr << "ERROR: Failed to write to recipe '" << argv[2] << "'" << std::endl; return 255; } return 0; |