Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions compiler/tflchef/core/src/Op/Sign.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 "Sign.h"

flatbuffers::Offset<void> SignChef::value(flatbuffers::FlatBufferBuilder &fbb) const
{
return flatbuffers::Offset<void>();
}

std::unique_ptr<OpChef> SignChefFactory::create(const tflchef::Operation *operation) const
{
return std::unique_ptr<OpChef>{new SignChef{operation}};
}
46 changes: 46 additions & 0 deletions compiler/tflchef/core/src/Op/Sign.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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_SIGN_H__
#define __OP_SIGN_H__

#include "OpChef.h"

class SignChef final : public OpChef
{
public:
explicit SignChef(const tflchef::Operation *operation) : _operation{operation}
{
// DO NOTHING
}

public:
tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_SIGN; }

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 SignChefFactory final : public OpChefFactory
{
std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override;
};

#endif // __OP_SIGN_H__
1 change: 1 addition & 0 deletions compiler/tflchef/core/src/OpChef.def
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ OP_CHEF(SegmentSum,SegmentSumChefFactory)
OP_CHEF(Select, SelectChefFactory)
OP_CHEF(SelectV2, SelectV2ChefFactory)
OP_CHEF(Shape, ShapeChefFactory)
OP_CHEF(Sign, SignChefFactory)
OP_CHEF(Sin, SinChefFactory)
OP_CHEF(Slice, SliceChefFactory)
OP_CHEF(Softmax, SoftmaxChefFactory)
Expand Down
1 change: 1 addition & 0 deletions compiler/tflchef/core/src/OpChefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
#include "Op/Select.h"
#include "Op/SelectV2.h"
#include "Op/Shape.h"
#include "Op/Sign.h"
#include "Op/Sin.h"
#include "Op/Slice.h"
#include "Op/Softmax.h"
Expand Down
40 changes: 40 additions & 0 deletions compiler/tflchef/tflite/src/Op/Sign.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 "Sign.h"

#include "Convert.h"

namespace tflchef
{

void TFliteOpSign::filler(const tflite::Operator *op, TFliteImport *import,
tflchef::ModelRecipe *model_recipe) const
{
// Nothing to do with filler
}

tflchef::Operation *TFliteOpSign::build(RecipeChefContext *ctx) const
{
tflchef::Operation *operation = ctx->chefop;
const tflite::Operator *op = ctx->tflop;

operation->set_type("Sign");

return operation;
}

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

#include "TFliteOpChef.h"

namespace tflchef
{

/**
* @brief tflchef operator builder for Sign
*/
class TFliteOpSign : public TFliteOpChef
{
public:
void filler(const tflite::Operator *op, TFliteImport *import,
tflchef::ModelRecipe *model_recipe) const override;
tflchef::Operation *build(RecipeChefContext *ctx) const override;
};

} // namespace tflchef

#endif // __TFLITE_OP_SIGN_H__
1 change: 1 addition & 0 deletions compiler/tflchef/tflite/src/TFliteOpChefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
#include "Op/include/Select.h"
#include "Op/include/SelectV2.h"
#include "Op/include/Shape.h"
#include "Op/include/Sign.h"
#include "Op/include/Sin.h"
#include "Op/include/Slice.h"
#include "Op/include/Softmax.h"
Expand Down
1 change: 1 addition & 0 deletions compiler/tflchef/tflite/src/TFliteOpRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class TFliteOpRegistry
REG_TFL_OP(SELECT, TFliteOpSelect);
REG_TFL_OP(SELECT_V2, TFliteOpSelectV2);
REG_TFL_OP(SHAPE, TFliteOpShape);
REG_TFL_OP(SIGN, TFliteOpSign);
REG_TFL_OP(SIN, TFliteOpSin);
REG_TFL_OP(SLICE, TFliteOpSlice);
REG_TFL_OP(SOFTMAX, TFliteOpSoftmax);
Expand Down