Skip to content

Commit

Permalink
Add options
Browse files Browse the repository at this point in the history
Signed-off-by: Dayoung Lee <[email protected]>
  • Loading branch information
dayo09 committed Oct 10, 2024
1 parent 63d7ff2 commit 0591915
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/circle2circle/src/Circle2Circle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ int entry(int argc, char **argv)
"it only converts weights whose row is a multiple of 16");
add_switch(arser, "--replace_non_const_fc_with_batch_matmul",
"Replace FullyConnected with BatchMatMul when its weight is non-constant");
add_switch(arser, "--substitute_expand_dims_to_reshape",
"This will convert ExpandDims with constant axis to Reshape");
add_switch(arser, "--substitute_pack_to_reshape",
"This will convert single input Pack to Reshape");
add_switch(arser, "--substitute_padv2_to_pad",
Expand Down Expand Up @@ -333,6 +335,7 @@ int entry(int argc, char **argv)
option_str_to_enum["resolve_former_customop"] = Algorithms::ResolveFormerCustomOp;
option_str_to_enum["shuffle_weight_to_16x1float32"] = Algorithms::ShuffleWeightTo16x1Float32;
option_str_to_enum["replace_non_const_fc_with_batch_matmul"] = Algorithms::ReplaceNonConstFCWithBatchMatMul;
option_str_to_enum["substitute_expand_dims_to_reshape"] = Algorithms::SubstituteExpandDimsToReshape;
option_str_to_enum["substitute_pack_to_reshape"] = Algorithms::SubstitutePackToReshape;
option_str_to_enum["substitute_padv2_to_pad"] = Algorithms::SubstitutePadV2ToPad;
option_str_to_enum["substitute_splitv_to_split"] = Algorithms::SubstituteSplitVToSplit;
Expand Down
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 @@ -86,6 +86,7 @@ class CircleOptimizer final
ReplaceNonConstFCWithBatchMatMul,
ReplaceSubWithAdd,
ReplaceWithFCGeluFC,
SubstituteExpandDimsToReshape,
SubstitutePackToReshape,
SubstitutePadV2ToPad,
SubstituteSplitVToSplit,
Expand Down
5 changes: 5 additions & 0 deletions compiler/luci/pass/src/CircleOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include "luci/Pass/ResolveFormerCustomOpPass.h"
#include "luci/Pass/SparsifyTensorPass.h"
#include "luci/Pass/ShuffleWeightTo16x1Float32Pass.h"
#include "luci/Pass/SubstituteExpandDimsToReshapePass.h"
#include "luci/Pass/SubstitutePackToReshapePass.h"
#include "luci/Pass/SubstitutePadV2ToPadPass.h"
#include "luci/Pass/SubstituteSplitVToSplitPass.h"
Expand Down Expand Up @@ -291,6 +292,10 @@ void CircleOptimizer::optimize(loco::Graph *g) const
// 1. SubstituteXXXToReshape
// 2. RemoveRedundantReshape/Transpose
// See https://github.com/Samsung/ONE/pull/10596 for more details
if (_options->query(Options::Algorithm::SubstituteExpandDimsToReshape))
{
phase.emplace_back(std::make_unique<luci::SubstituteExpandDimsToReshapePass>());
}
if (_options->query(Options::Algorithm::SubstitutePackToReshape))
{
phase.emplace_back(std::make_unique<luci::SubstitutePackToReshapePass>());
Expand Down
3 changes: 3 additions & 0 deletions compiler/one-cmds/onelib/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CONSTANT:
'resolve_customop_matmul',
'resolve_customop_max_pool_with_argmax',
'resolve_customop_splitv',
'substitute_expand_dims_to_reshape',
'substitute_pack_to_reshape',
'substitute_padv2_to_pad',
'substitute_splitv_to_split',
Expand Down Expand Up @@ -179,6 +180,8 @@ class CONSTANT:
('shuffle_weight_to_16x1float32',
'convert weight format of FullyConnected op to SHUFFLED16x1FLOAT32.'
' Note that it only converts weights whose row is a multiple of 16'),
('substitute_expand_dims_to_reshape',
'convert ExpandDims with constant axis to Reshape op'),
('substitute_pack_to_reshape', 'convert single input Pack op to Reshape op'),
('substitute_padv2_to_pad', 'convert certain condition PadV2 to Pad'),
('substitute_splitv_to_split', 'convert certain condition SplitV to Split'),
Expand Down

0 comments on commit 0591915

Please sign in to comment.