Skip to content

Commit

Permalink
Merge branch 'Samsung:master' into rope/luci/lang
Browse files Browse the repository at this point in the history
  • Loading branch information
ys44kim authored Sep 24, 2024
2 parents d4df5e6 + e865a10 commit 619a733
Show file tree
Hide file tree
Showing 105 changed files with 2,291 additions and 868 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defaults:
jobs:
check-format:
name: Check format
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
if: github.repository_owner == 'Samsung'

steps:
Expand All @@ -29,15 +29,10 @@ jobs:
with:
python-version: '3.x'

# C format: clang-format-16
# C format: clang-format-16 (already installed)
# Python format: yapf==0.40.2
- name: Install packages
run: |
sudo apt-get install -y gnupg2 software-properties-common
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main"
sudo apt-get update && sudo apt-get install -qqy clang-format-16
python -m pip install --upgrade pip
pip install yapf==0.40.2
- name: Check
Expand Down
2 changes: 1 addition & 1 deletion Makefile.template
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ runtime_tar_internal:
tar -zcf $(WORKSPACE)/onert-test-package.tar.gz -C $(INSTALL_PATH) $(shell ls $(INSTALL_PATH) -I lib -I include)

acl_tar_internal:
tar -zcf $(WORKSPACE)/onert-acl.tar.gz -C ${OVERLAY_FOLDER} lib/libarm_compute.so lib/libarm_compute_core.so lib/libarm_compute_graph.so
tar -zcf $(WORKSPACE)/onert-acl.tar.gz -C ${OVERLAY_FOLDER} lib/libarm_compute.so lib/libarm_compute_graph.so

install_acl_internal:
# Workaround to install acl for test (ignore error when there is no file to copy)
Expand Down
15 changes: 15 additions & 0 deletions compiler/circledump/src/OpPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,20 @@ class InstanceNormPrinter : public OpPrinter
}
};

class RmsNormPrinter : public OpPrinter
{
public:
void options(const circle::Operator *op, std::ostream &os) const override
{
if (auto *params = op->builtin_options_as_RmsNormOptions())
{
os << " ";
os << "epsilon(" << params->epsilon() << ") ";
os << std::endl;
}
}
};

OpPrinterRegistry::OpPrinterRegistry()
{
_op_map[circle::BuiltinOperator_ADD] = make_unique<AddPrinter>();
Expand Down Expand Up @@ -912,6 +926,7 @@ OpPrinterRegistry::OpPrinterRegistry()
_op_map[circle::BuiltinOperator_BCQ_GATHER] = make_unique<BCQGatherPrinter>();
_op_map[circle::BuiltinOperator_GRU] = make_unique<GRUPrinter>();
_op_map[circle::BuiltinOperator_INSTANCE_NORM] = make_unique<InstanceNormPrinter>();
_op_map[circle::BuiltinOperator_RMS_NORM] = make_unique<RmsNormPrinter>();
}

} // namespace circledump
2 changes: 2 additions & 0 deletions compiler/common-artifacts/exclude.lst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ optimize(Add_STR_000) # STRING is not supported
optimize(Add_STR_001) # STRING is not supported

## CircleRecipes
optimize(RmsNorm_000)

#[[ tcgenerate : Exclude from test data generation(TestDataGenerator) ]]
## TensorFlowLiteRecipes
Expand Down Expand Up @@ -178,3 +179,4 @@ tcgenerate(CircleFullyConnected_U4_002)
tcgenerate(GRU_000) # luci-interpreter does not support custom GRU
tcgenerate(InstanceNorm_000)
tcgenerate(InstanceNorm_001)
tcgenerate(RmsNorm_000)
10 changes: 6 additions & 4 deletions compiler/logo/src/Passes/RemoveDeadNodeWithQueryPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ bool RemoveDeadNodeWithQueryPass::run(loco::Graph *g)
}

// Find the nodes that should not be dead node in candidates
for (auto node : candidates)
for (auto it = candidates.begin(); it != candidates.end();)
{
if (auto service = node->dialect()->service<DeadNodeQueryService>())
if (auto service = (*it)->dialect()->service<DeadNodeQueryService>())
{
if (!service->isDeadNode(node))
if (!service->isDeadNode(*it))
{
candidates.erase(node);
it = candidates.erase(it);
continue;
}
}
++it;
}

for (auto node : candidates)
Expand Down
4 changes: 4 additions & 0 deletions compiler/luci/export/src/CircleBuiltinTypesExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ class BuiltinOptionsExtractor final
to_circle_actfunc(node->fusedActivationFunction()))
.Union();
}
flatbuffers::Offset<void> visit(luci::CircleRmsNorm *node)
{
return circle::CreateRmsNormOptions(_builder, node->epsilon()).Union();
}

protected:
flatbuffers::FlatBufferBuilder &_builder;
Expand Down
2 changes: 1 addition & 1 deletion compiler/luci/export/src/CircleExporterUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ CircleTensorIndex get_tensor_index(loco::Node *node);
// check if Flatbuffer builder can no longer hold the given amount of the data
inline bool check_size_limit(const flatbuffers::FlatBufferBuilder &fb, const uint64_t data_size)
{
return data_size > FLATBUFFERS_SIZE_MAX - fb.GetSize();
return FLATBUFFERS_SIZE_MAX < data_size + fb.GetSize();
}

} // namespace luci
Expand Down
1 change: 1 addition & 0 deletions compiler/luci/export/src/CircleOps.lst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ CIRCLE_NODE(CircleBCQFullyConnected, BuiltinOperator_BCQ_FULLY_CONNECTED, Builti
CIRCLE_NODE(CircleBCQGather, BuiltinOperator_BCQ_GATHER, BuiltinOptions_BCQGatherOptions)
CIRCLE_NODE(CircleGRU, BuiltinOperator_GRU, BuiltinOptions_GRUOptions)
CIRCLE_NODE(CircleInstanceNorm, BuiltinOperator_INSTANCE_NORM, BuiltinOptions_InstanceNormOptions)
CIRCLE_NODE(CircleRmsNorm, BuiltinOperator_RMS_NORM, BuiltinOptions_RmsNormOptions)
// Virtual node(s)
CIRCLE_VNODE(CircleBidirectionalSequenceLSTMOut)
CIRCLE_VNODE(CircleConst)
Expand Down
1 change: 1 addition & 0 deletions compiler/luci/import/include/luci/Import/Nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
#include "Nodes/CircleResizeNearestNeighbor.h"
#include "Nodes/CircleReverseSequence.h"
#include "Nodes/CircleReverseV2.h"
#include "Nodes/CircleRmsNorm.h"
#include "Nodes/CircleRound.h"
#include "Nodes/CircleRsqrt.h"
#include "Nodes/CircleScatterNd.h"
Expand Down
37 changes: 37 additions & 0 deletions compiler/luci/import/include/luci/Import/Nodes/CircleRmsNorm.h
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__
1 change: 1 addition & 0 deletions compiler/luci/import/src/GraphBuilderRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ GraphBuilderRegistry::GraphBuilderRegistry()
CIRCLE_NODE(RESIZE_NEAREST_NEIGHBOR, CircleResizeNearestNeighborGraphBuilder); // 97
CIRCLE_NODE(REVERSE_SEQUENCE, CircleReverseSequenceGraphBuilder); // 112
CIRCLE_NODE(REVERSE_V2, CircleReverseV2GraphBuilder); // 105
CIRCLE_NODE(RMS_NORM, CircleRmsNormGraphBuilder); // 255
CIRCLE_NODE(ROUND, CircleRoundGraphBuilder); // 116
CIRCLE_NODE(RSQRT, CircleRsqrtGraphBuilder); // 76
CIRCLE_NODE(SCATTER_ND, CircleScatterNdGraphBuilder); // 122
Expand Down
47 changes: 47 additions & 0 deletions compiler/luci/import/src/Nodes/CircleRmsNorm.cpp
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
1 change: 1 addition & 0 deletions compiler/luci/logex/src/CircleNodeSummaryBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ CircleNodeSummaryBuilder::create_builder(const luci::CircleNode *node)
CIRCLE_NODE(RESIZE_NEAREST_NEIGHBOR, CircleResizeNearestNeighborSummaryBuilder)
CIRCLE_NODE(REVERSE_SEQUENCE, CircleReverseSequenceSummaryBuilder)
CIRCLE_NODE(REVERSE_V2, CircleReverseV2SummaryBuilder)
CIRCLE_NODE(RMS_NORM, CircleRmsNormSummaryBuilder)
CIRCLE_NODE(ROUND, CircleRoundSummaryBuilder)
CIRCLE_NODE(RSQRT, CircleRsqrtSummaryBuilder)
CIRCLE_NODE(SCATTER_ND, CircleScatterNdSummaryBuilder)
Expand Down
12 changes: 12 additions & 0 deletions compiler/luci/logex/src/CircleNodeSummaryBuilders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,18 @@ std::vector<std::string> CircleReverseV2SummaryBuilder::get_input_names(const lu
return {"tensor", "axis"};
}

std::vector<std::string> CircleRmsNormSummaryBuilder::get_input_names(const luci::CircleNode *)
{
return {"input", "gamma", "beta"};
}

void CircleRmsNormSummaryBuilder::build_attributes(const luci::CircleNode *node,
locop::NodeSummary &s)
{
auto rmsnorm = loco::must_cast<const luci::CircleRmsNorm *>(node);
s.args().append("epsilon", std::to_string(rmsnorm->epsilon()));
}

std::vector<std::string> CircleScatterNdSummaryBuilder::get_input_names(const luci::CircleNode *)
{
return {"indices", "updates", "shape"};
Expand Down
7 changes: 7 additions & 0 deletions compiler/luci/logex/src/CircleNodeSummaryBuilders.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ class CircleReverseV2SummaryBuilder final : public CircleNodeSummaryBuilder
std::vector<std::string> get_input_names(const luci::CircleNode *);
};

class CircleRmsNormSummaryBuilder final : public CircleNodeSummaryBuilder
{
private:
std::vector<std::string> get_input_names(const luci::CircleNode *);
void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
};

class CircleRoundSummaryBuilder final : public CircleNodeWithXSummaryBuilder
{
};
Expand Down
1 change: 1 addition & 0 deletions compiler/luci/partition/include/luci/ConnectNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class ConnectNode final : public luci::CircleNodeVisitor<void>
void visit(const luci::CircleBCQGather *) final;
void visit(const luci::CircleGRU *) final;
void visit(const luci::CircleInstanceNorm *) final;
void visit(const luci::CircleRmsNorm *) final;

// NOTE CircleInput and CircleOutput are not handled here as these need
// link with graph I/O
Expand Down
42 changes: 42 additions & 0 deletions compiler/luci/partition/src/Nodes/CircleRmsNorm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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/ConnectNode.h"

namespace
{

void connect(luci::ConnectNode *cn, const luci::CircleRmsNorm *node)
{
auto *cloned = loco::must_cast<luci::CircleRmsNorm *>(cn->find_clone(node));

luci::CircleNode *input = loco::must_cast<luci::CircleNode *>(node->input());
luci::CircleNode *gamma = loco::must_cast<luci::CircleNode *>(node->gamma());
luci::CircleNode *beta = loco::must_cast<luci::CircleNode *>(node->beta());

cloned->input(cn->find_clone(input));
cloned->gamma(cn->find_clone(gamma));
cloned->beta(cn->find_clone(beta));
}

} // namespace

namespace luci
{

void ConnectNode::visit(const luci::CircleRmsNorm *node) { connect(this, node); }

} // namespace luci
Loading

0 comments on commit 619a733

Please sign in to comment.