forked from Samsung/ONE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this commits support RoPE for circle chef ONE-DCO-1.0-Signed-off-by: youngsik kim <[email protected]> draft : Samsung#13978 issue : Samsung#13972
- Loading branch information
Showing
9 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT 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 "RoPE.h" | ||
|
||
#include "Convert.h" | ||
|
||
namespace circlechef | ||
{ | ||
|
||
void CircleOpRoPE::filler(const circle::Operator *op, CircleImport *import, | ||
circlechef::ModelRecipe *model_recipe) const | ||
{ | ||
const std::vector<int32_t> &inputs = as_index_vector(op->inputs()); | ||
|
||
// To Do: input parameters | ||
assert(inputs.size() == 3); | ||
} | ||
|
||
circlechef::Operation *CircleOpRoPE::build(const circle::Operator *op, CircleImport *import, | ||
circlechef::ModelRecipe *model_recipe) const | ||
{ | ||
auto operation = model_recipe->add_operation(); | ||
|
||
operation->set_type("RoPE"); | ||
|
||
auto op_options = operation->mutable_rope_options(); | ||
|
||
auto op_params = op->builtin_options_as_RoPEOptions(); | ||
assert(op_params != nullptr); | ||
|
||
op_options->set_mode(op_params->mode()); | ||
|
||
return operation; | ||
} | ||
|
||
} // namespace circlechef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT 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 __CIRCLE_OP_ROPE_H__ | ||
#define __CIRCLE_OP_ROPE_H__ | ||
|
||
#include "CircleOpChef.h" | ||
|
||
namespace circlechef | ||
{ | ||
|
||
/** | ||
* @brief circlechef operator builder for RoPE | ||
*/ | ||
class CircleOpRoPE : public CircleOpChef | ||
{ | ||
public: | ||
void filler(const circle::Operator *op, CircleImport *import, | ||
circlechef::ModelRecipe *model_recipe) const override; | ||
circlechef::Operation *build(const circle::Operator *op, CircleImport *import, | ||
circlechef::ModelRecipe *model_recipe) const override; | ||
}; | ||
|
||
} // namespace circlechef | ||
|
||
#endif // __CIRCLE_OP_ROPE_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT 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 "RoPE.h" | ||
|
||
#include "Convert.h" | ||
|
||
flatbuffers::Offset<void> RoPEChef::value(flatbuffers::FlatBufferBuilder &fbb) const | ||
{ | ||
auto &operation = (*_operation); | ||
assert(operation.has_rope_options()); | ||
|
||
circle::RoPEOptionsBuilder options_builder{fbb}; | ||
options_builder.add_mode(static_cast<circle::RoPEMode>(operation.rope_options().mode())); | ||
|
||
return options_builder.Finish().Union(); | ||
} | ||
|
||
std::unique_ptr<OpChef> | ||
RoPEChefFactory::create(const circlechef::Operation *operation) const | ||
{ | ||
return std::unique_ptr<OpChef>{new RoPEChef{operation}}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT 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_ROPE_H__ | ||
#define __OP_ROPE_H__ | ||
|
||
#include "OpChef.h" | ||
|
||
class RoPEChef final : public OpChef | ||
{ | ||
public: | ||
explicit RoPEChef(const circlechef::Operation *operation) : _operation{operation} | ||
{ | ||
// DO NOTHING | ||
} | ||
|
||
public: | ||
circle::BuiltinOperator code(void) const override | ||
{ | ||
return circle::BuiltinOperator_ROPE; | ||
} | ||
|
||
circle::BuiltinOptions type(void) const override | ||
{ | ||
return circle::BuiltinOptions_RoPEOptions; | ||
} | ||
|
||
flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override; | ||
|
||
private: | ||
const circlechef::Operation *_operation; | ||
}; | ||
|
||
struct RoPEChefFactory final : public OpChefFactory | ||
{ | ||
std::unique_ptr<OpChef> create(const circlechef::Operation *operation) const override; | ||
}; | ||
|
||
#endif // __OP_ROPE_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters