Skip to content

Commit

Permalink
[luci/pass] Introduce RemoveUnnecessaryTransposeNetPass (Samsung#11976)
Browse files Browse the repository at this point in the history
This PR introduces RemoveUnnecessaryTransposeNetPass and related unit tests.

ONE-DCO-1.0-Signed-off-by: SeungHui Youn <[email protected]>
  • Loading branch information
zetwhite authored Nov 10, 2023
1 parent ee6e037 commit c492527
Show file tree
Hide file tree
Showing 5 changed files with 755 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/luci/pass/include/luci/CircleOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CircleOptimizer final
RemoveUnnecessaryStridedSlice,
RemoveUnnecessarySplit,
RemoveUnnecessaryReshape,
RemoveUnnecessaryTranspose,
TransformMinMaxToRelu6Pass,
TransformMinReluToRelu6Pass,
DecomposeHardSwishPass,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2023 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_REMOVE_UNNECESSARY_TRANSPOSE_NET_PASS_H__
#define __LUCI_REMOVE_UNNECESSARY_TRANSPOSE_NET_PASS_H__

#include <logo/Pass.h>

namespace luci
{

struct RemoveUnnecessaryTransposeNetPass final : public logo::Pass
{
const char *name(void) const final { return "luci::RemoveUnnecessaryTransposeNetPass"; }

bool run(loco::Graph *g) final;
};

} // namespace luci

#endif // __LUCI_REMOVE_UNNECESSARY_TRANSPOSE_NET_PASS_H__
5 changes: 5 additions & 0 deletions compiler/luci/pass/src/CircleOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "luci/Pass/RemoveUnnecessarySlicePass.h"
#include "luci/Pass/RemoveUnnecessaryStridedSlicePass.h"
#include "luci/Pass/RemoveUnnecessarySplitPass.h"
#include "luci/Pass/RemoveUnnecessaryTransposeNetPass.h"
#include "luci/Pass/ReplaceNonConstFCWithBatchMatMulPass.h"
#include "luci/Pass/ReplaceMulAddWithDepthwiseConvPass.h"
#include "luci/Pass/ReplaceSubWithAddPass.h"
Expand Down Expand Up @@ -401,6 +402,10 @@ void CircleOptimizer::optimize(loco::Graph *g) const
{
phase.emplace_back(std::make_unique<luci::RemoveUnnecessarySplitPass>());
}
if (_options->query(Options::Algorithm::RemoveUnnecessaryTranspose))
{
phase.emplace_back(std::make_unique<luci::RemoveUnnecessaryTransposeNetPass>());
}
if (_options->query(Options::Algorithm::RemoveRedundantReshape))
{
phase.emplace_back(std::make_unique<luci::RemoveRedundantReshapePass>());
Expand Down
Loading

0 comments on commit c492527

Please sign in to comment.