2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __LUCI_CIRCLE_OPTIMIZER_H__
18 #define __LUCI_CIRCLE_OPTIMIZER_H__
22 #include <luci/IR/Module.h>
30 class CircleOptimizer final
37 FuseAddWithFullyConnected,
39 FuseBatchNormWithConv,
40 FuseBatchNormWithDwConv,
41 FuseBatchNormWithTConv,
45 FuseTransposeWithMean,
47 ResolveCustomOpBatchMatMul,
48 ResolveCustomOpMatMul,
49 ResolveCustomOpMaxPoolWithArgmax,
50 ResolveCustomOpSplitV,
59 ForwardReshapeToUnaryOp,
62 FusePreActivationBatchNorm,
63 MakeBatchNormGammaPositive,
64 FuseActivationFunction,
66 ShuffleWeightTo16x1Float32,
67 RemoveRedundantTranspose,
68 ReplaceMulAddWithDepthwiseConv,
69 ReplaceNonConstFCWithBatchMatMul,
71 SubstitutePackToReshape,
73 SubstituteSplitVToSplit,
74 SubstituteSqueezeToReshape,
77 RemoveUnnecessarySlice,
78 RemoveUnnecessaryStridedSlice,
79 RemoveUnnecessarySplit,
80 RemoveUnnecessaryReshape,
81 TransformMinMaxToRelu6Pass,
82 TransformMinReluToRelu6Pass,
83 SubstituteStridedSliceToReshape,
84 SubstituteTransposeToReshape,
85 RemoveRedundantQuantize,
86 RemoveRedundantReshape,
88 RemoveQuantDequantSeq,
93 enum AlgorithmParameters
97 Sparsify_traversal_order,
102 // convert NCHW to NHWC
103 NCHW_to_NHWC_input_shape,
104 NCHW_to_NHWC_output_shape,
107 virtual ~Options() = default;
109 virtual void enable(Algorithm) = 0;
110 virtual bool query(Algorithm) = 0;
111 virtual void param(AlgorithmParameters, const std::string &) = 0;
112 virtual const std::string param(AlgorithmParameters) const = 0;
116 // TODO maybe caller can provide Options as ctor parameters
117 Options *options(void);
120 void optimize(luci::Module *) const;
122 void optimize(loco::Graph *) const;
124 void sparsify(loco::Graph *) const;
127 std::unique_ptr<Options> _options;
132 #endif // __LUCI_CIRCLE_OPTIMIZER_H__