-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
on-going draft to support new tflite/circle schema. Signed-off-by: SaeHie Park <[email protected]>
- Loading branch information
1 parent
2c45b55
commit bae1d1f
Showing
48 changed files
with
501 additions
and
6 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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
compiler/luci/pass/include/luci/Pass/XpSepActFromTransposeConvPass.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) 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_XP_SEP_ACT_FROM_TRANSPOSE_CONV_PASS_H__ | ||
#define __LUCI_XP_SEP_ACT_FROM_TRANSPOSE_CONV_PASS_H__ | ||
|
||
#include <logo/Pass.h> | ||
|
||
namespace luci | ||
{ | ||
|
||
/** | ||
* @brief Experimental Class to separate activation functions from TransposeConv | ||
*/ | ||
struct XpSepActFromTransposeConvPass final : public logo::Pass | ||
{ | ||
const char *name(void) const final { return "luci::XpSepActFromTransposeConvPass"; } | ||
|
||
bool run(loco::Graph *g) final; | ||
}; | ||
|
||
} // namespace luci | ||
|
||
#endif // __LUCI_XP_SEP_ACT_FROM_TRANSPOSE_CONV_PASS_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
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,94 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "luci/Pass/XpSepActFromTransposeConvPass.h" | ||
|
||
#include <luci/IR/CircleNodes.h> | ||
#include <luci/IR/CircleNodeMixins.h> | ||
#include <luci/Profile/CircleNodeOrigin.h> | ||
|
||
namespace luci | ||
{ | ||
|
||
namespace | ||
{ | ||
|
||
bool separate_activation_fuction(luci::CircleTransposeConv *trconv) | ||
{ | ||
auto fused_act = trconv->fusedActivationFunction(); | ||
if (fused_act == luci::FusedActFunc::NONE) | ||
return false; | ||
if (fused_act == luci::FusedActFunc::UNDEFINED) | ||
throw std::runtime_error("ACT UNDEFINED !!!"); | ||
|
||
// NOTE features() is call after replace().with(); | ||
// calling loco::replace(trconv).with(actnode) will also update actnode itself | ||
// which will make totally wrong result with input of actnode is itself. | ||
|
||
auto name = trconv->name(); | ||
luci::CircleNode *actnode = nullptr; | ||
switch (fused_act) | ||
{ | ||
case luci::FusedActFunc::RELU: | ||
{ | ||
auto af = trconv->graph()->nodes()->create<luci::CircleRelu>(); | ||
loco::replace(trconv).with(af); | ||
af->features(trconv); | ||
af->name(name + "/Relu"); | ||
actnode = af; | ||
} | ||
break; | ||
case luci::FusedActFunc::RELU6: | ||
{ | ||
auto af = trconv->graph()->nodes()->create<luci::CircleRelu6>(); | ||
loco::replace(trconv).with(af); | ||
af->features(trconv); | ||
af->name(name + "/Relu6"); | ||
actnode = af; | ||
} | ||
break; | ||
// TODO support more | ||
default: | ||
return false; | ||
} | ||
assert(actnode != nullptr); | ||
actnode->dtype(trconv->dtype()); | ||
luci::add_origin(actnode, luci::get_origin(trconv)); | ||
|
||
trconv->fusedActivationFunction(luci::FusedActFunc::NONE); | ||
|
||
return true; | ||
} | ||
|
||
} // namespace | ||
|
||
bool XpSepActFromTransposeConvPass::run(loco::Graph *g) | ||
{ | ||
bool changed = false; | ||
for (auto node : loco::active_nodes(loco::output_nodes(g))) | ||
{ | ||
auto trconv = dynamic_cast<luci::CircleTransposeConv *>(node); | ||
if (trconv != nullptr) | ||
{ | ||
if (separate_activation_fuction(trconv)) | ||
changed = true; | ||
} | ||
} | ||
|
||
return changed; | ||
} | ||
|
||
} // namespace luci |
Oops, something went wrong.