f681b3d5fbb3710176a20a0e54cfa73c2c829631
[platform/core/ml/nnfw.git] / compiler / luci / pass / src / ShapeInferencePass.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
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
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "luci/Pass/ShapeInferencePass.h"
18
19 #include <luci/IR/CircleDialect.h>
20 #include <luci/Service/CircleShapeInferenceRule.h>
21
22 #include <loco.h>
23 #include <loco/IR/CanonicalDialect.h>
24 #include <loco/Service/CanonicalShapeInferenceRule.h>
25 #include <loco/Service/ShapeInference.h>
26 #include <loco/Service/MultiDialectShapeInferenceRule.h>
27
28 namespace luci
29 {
30
31 bool ShapeInferencePass::run(loco::Graph *g)
32 {
33   loco::CanonicalShapeInferenceRule canonical_rule;
34   luci::CircleShapeInferenceRule circle_rule;
35
36   loco::MultiDialectShapeInferenceRule rules;
37
38   rules.bind(loco::CanonicalDialect::get(), &canonical_rule)
39       .bind(luci::CircleDialect::get(), &circle_rule);
40
41   return loco::apply(&rules).to(g);
42 }
43
44 } // namespace luci