ncnn

Форк
0
/
ncnn_rewriter.cpp 
54 строки · 1.6 Кб
1
// Tencent is pleased to support the open source community by making ncnn available.
2
//
3
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4
//
5
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6
// in compliance with the License. You may obtain a copy of the License at
7
//
8
// https://opensource.org/licenses/BSD-3-Clause
9
//
10
// Unless required by applicable law or agreed to in writing, software distributed
11
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
// specific language governing permissions and limitations under the License.
14

15
#include <mlir/IR/MLIRContext.h>
16
#include <mlir/IR/PatternMatch.h>
17
#include <mlir/Pass/Pass.h>
18
#include <mlir/Transforms/GreedyPatternRewriteDriver.h>
19

20
#include "tf_dialect.h"
21
#include "ncnn_dialect.h"
22

23
using namespace mlir;
24

25
namespace mlir {
26

27
namespace ncnn {
28

29
#include "ncnn_rewriter.inc"
30

31
class NCNNOptimizePass : public PassWrapper<NCNNOptimizePass, FunctionPass>
32
{
33
public:
34
    void runOnFunction();
35
};
36

37
void NCNNOptimizePass::runOnFunction()
38
{
39
    mlir::OwningRewritePatternList patterns;
40
    mlir::ncnn::populateWithGenerated(&getContext(), patterns);
41

42
    (void)mlir::applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
43
}
44

45
std::unique_ptr<OperationPass<FuncOp> > createNCNNOptimizePass()
46
{
47
    return std::make_unique<NCNNOptimizePass>();
48
}
49

50
static PassRegistration<NCNNOptimizePass> pass("ncnn-optimize", "ncnn optimization");
51

52
} // namespace ncnn
53

54
} // namespace mlir
55

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.