Skip to content

Commit

Permalink
[tflite2circle] support SVDF for circle conversion (Samsung#8204)
Browse files Browse the repository at this point in the history
This commit enables SVDF Op for circle conversion

ONE-DCO-1.0-Signed-off-by: Artem Balyshev [email protected]
Co-authored-by: Balyshev Artem <[email protected]>
  • Loading branch information
BalyshevArtem and Balyshev Artem authored Dec 31, 2021
1 parent d862fdc commit b4645f9
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions compiler/tflite2circle/src/BuildBuiltinOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
#include "BuildBuiltinOptions/SqueezeOptions.h"
#include "BuildBuiltinOptions/StridedSliceOptions.h"
#include "BuildBuiltinOptions/SubOptions.h"
#include "BuildBuiltinOptions/SVDFOptions.h"
#include "BuildBuiltinOptions/TileOptions.h"
#include "BuildBuiltinOptions/TopKV2Options.h"
#include "BuildBuiltinOptions/TransposeOptions.h"
Expand Down
41 changes: 41 additions & 0 deletions compiler/tflite2circle/src/BuildBuiltinOptions/SVDFOptions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 "SVDFOptions.h"
#include "DataLookup.h"

#include <cassert>

namespace tflite2circle
{

flatbuffers::Offset<circle::SVDFOptions>
build_circle_SVDFOptions(flatbuffers::FlatBufferBuilder &fb, const tflite::Operator *op)
{
auto *tflite_builtin_options = op->builtin_options_as_SVDFOptions();
assert(tflite_builtin_options);

circle::SVDFOptionsBuilder builtin_options_builder{fb};
builtin_options_builder.add_rank(tflite_builtin_options->rank());
builtin_options_builder.add_asymmetric_quantize_inputs(
tflite_builtin_options->asymmetric_quantize_inputs());
builtin_options_builder.add_fused_activation_function(
get_circle_activation_function_type(tflite_builtin_options->fused_activation_function()));

return builtin_options_builder.Finish();
}

} // namespace tflite2circle
31 changes: 31 additions & 0 deletions compiler/tflite2circle/src/BuildBuiltinOptions/SVDFOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 __BBO_SVDF_OPTIONS_H__
#define __BBO_SVDF_OPTIONS_H__

#include <mio/tflite/schema_generated.h>
#include <mio/circle/schema_generated.h>

namespace tflite2circle
{

flatbuffers::Offset<circle::SVDFOptions>
build_circle_SVDFOptions(flatbuffers::FlatBufferBuilder &fb, const tflite::Operator *op);

} // namespace tflite2circle

#endif // __BBO_SVDF_OPTIONS_H__
2 changes: 1 addition & 1 deletion compiler/tflite2circle/src/TFLBuiltinOptions.lst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TFL_BUILTIN_OPTIONS(DepthwiseConv2DOptions)
//TFL_BUILTIN_OPTIONS(ConcatEmbeddingsOptions)
//TFL_BUILTIN_OPTIONS(LSHProjectionOptions)
TFL_BUILTIN_OPTIONS(Pool2DOptions)
//TFL_BUILTIN_OPTIONS(SVDFOptions)
TFL_BUILTIN_OPTIONS(SVDFOptions)
//TFL_BUILTIN_OPTIONS(RNNOptions)
TFL_BUILTIN_OPTIONS(FullyConnectedOptions)
TFL_BUILTIN_OPTIONS(SoftmaxOptions)
Expand Down

0 comments on commit b4645f9

Please sign in to comment.