-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[luci/import] Support RmsNorm operation (#14023)
This commit is to support RmsNorm operation in luci-import. ONE-DCO-1.0-Signed-off-by: Seockho Kim [email protected]
- Loading branch information
1 parent
d4d3bf9
commit 9028169
Showing
4 changed files
with
86 additions
and
0 deletions.
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
37 changes: 37 additions & 0 deletions
37
compiler/luci/import/include/luci/Import/Nodes/CircleRmsNorm.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,37 @@ | ||
/* | ||
* 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 __LUCI_IMPORT_OP_CIRCLE_RMS_NORM_H__ | ||
#define __LUCI_IMPORT_OP_CIRCLE_RMS_NORM_H__ | ||
|
||
#include "luci/Import/GraphBuilder.h" | ||
|
||
namespace luci | ||
{ | ||
|
||
class CircleRmsNormGraphBuilder : public GraphBuilder | ||
{ | ||
public: | ||
bool validate(const ValidateArgs &args) const final; | ||
|
||
private: | ||
CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs, | ||
loco::Graph *graph) const final; | ||
}; | ||
|
||
} // namespace luci | ||
|
||
#endif // __LUCI_IMPORT_OP_CIRCLE_RMS_NORM_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 "luci/Import/Nodes/CircleRmsNorm.h" | ||
|
||
#include <luci/IR/Nodes/CircleRmsNorm.h> | ||
|
||
#include <loco.h> | ||
|
||
namespace luci | ||
{ | ||
|
||
bool CircleRmsNormGraphBuilder::validate(const ValidateArgs &args) const | ||
{ | ||
// TODO check dtypes | ||
return GraphBuilder::validate(args, 3); | ||
} | ||
|
||
CircleNode *CircleRmsNormGraphBuilder::build_node(const circle::OperatorT &op, | ||
const std::vector<CircleNode *> &inputs, | ||
loco::Graph *graph) const | ||
{ | ||
auto *node = graph->nodes()->create<CircleRmsNorm>(); | ||
node->input(inputs.at(0)); | ||
node->gamma(inputs.at(1)); | ||
node->beta(inputs.at(2)); | ||
|
||
const auto *options = op.builtin_options.AsRmsNormOptions(); | ||
node->epsilon(options->epsilon); | ||
|
||
return node; | ||
} | ||
|
||
} // namespace luci |