2019-06-17 20:10:35 +08:00
|
|
|
//
|
|
|
|
|
// PoolGrad.cpp
|
|
|
|
|
// MNN
|
|
|
|
|
//
|
|
|
|
|
// Created by MNN on 2019/04/22.
|
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "PoolGrad.hpp"
|
2019-12-27 22:16:57 +08:00
|
|
|
#include "core/Macro.h"
|
2019-06-17 20:10:35 +08:00
|
|
|
using namespace std;
|
|
|
|
|
using namespace MNN;
|
- dynamic computation graph (beta)
- add supports (/express)
- add tests
- add benchmarks with it (/benchmark/exprModels)
- Python
- MNN engine and tools were submitted to pip
- available on Windows/macOS/Linux
- Engine/Converter
- add supports for each op benchmarking
- refactor optimizer by separating steps
- CPU
- add supports for Conv3D, Pool3D, ELU, ReverseSequence
- fix ArgMax, Permute, Scale, BinaryOp, Slice, SliceTf
- OpenCL
- add half transform in CPU
- add broadcast supports for binary
- optimize Conv2D, Reshape, Eltwise, Gemm, etc.
- OpenGL
- add sub, real div supports for binary
- add supports for unary
- optimize Conv2D, Reshape
- Vulkan
- add max supports for eltwise
- Metal
- fix metallib missing problem
- Train/Quantization
- use express to refactor training codes
2019-09-26 21:02:07 +08:00
|
|
|
using namespace MNN::Express;
|
2019-06-17 20:10:35 +08:00
|
|
|
|
|
|
|
|
class PoolGrad : public OpGrad {
|
|
|
|
|
public:
|
|
|
|
|
PoolGrad() {
|
|
|
|
|
mType = SEMI_LINEAR;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-15 13:33:47 +08:00
|
|
|
virtual std::vector<Express::VARP> onGrad(Express::EXPRP expr,
|
2019-12-27 22:16:57 +08:00
|
|
|
const std::vector<Express::VARP>& backwardOutput) override {
|
|
|
|
|
std::vector<Express::VARP> result(1, nullptr);
|
- dynamic computation graph (beta)
- add supports (/express)
- add tests
- add benchmarks with it (/benchmark/exprModels)
- Python
- MNN engine and tools were submitted to pip
- available on Windows/macOS/Linux
- Engine/Converter
- add supports for each op benchmarking
- refactor optimizer by separating steps
- CPU
- add supports for Conv3D, Pool3D, ELU, ReverseSequence
- fix ArgMax, Permute, Scale, BinaryOp, Slice, SliceTf
- OpenCL
- add half transform in CPU
- add broadcast supports for binary
- optimize Conv2D, Reshape, Eltwise, Gemm, etc.
- OpenGL
- add sub, real div supports for binary
- add supports for unary
- optimize Conv2D, Reshape
- Vulkan
- add max supports for eltwise
- Metal
- fix metallib missing problem
- Train/Quantization
- use express to refactor training codes
2019-09-26 21:02:07 +08:00
|
|
|
auto outputDiff = backwardOutput[0];
|
|
|
|
|
std::unique_ptr<OpT> forwardOp(expr->get()->UnPack());
|
2019-06-17 20:10:35 +08:00
|
|
|
unique_ptr<OpT> newOp(new OpT);
|
2019-12-27 22:16:57 +08:00
|
|
|
newOp->type = OpType_PoolGrad;
|
|
|
|
|
auto copyP = new PoolT(*forwardOp->main.AsPool());
|
|
|
|
|
newOp->main.type = OpParameter_Pool;
|
|
|
|
|
newOp->main.value = copyP;
|
|
|
|
|
|
2020-01-15 13:33:47 +08:00
|
|
|
result[0] = Variable::create(
|
|
|
|
|
Expr::create(std::move(newOp), {expr->inputs()[0], Variable::create(expr, 0), outputDiff}));
|
2019-06-17 20:10:35 +08:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
};
|
- dynamic computation graph (beta)
- add supports (/express)
- add tests
- add benchmarks with it (/benchmark/exprModels)
- Python
- MNN engine and tools were submitted to pip
- available on Windows/macOS/Linux
- Engine/Converter
- add supports for each op benchmarking
- refactor optimizer by separating steps
- CPU
- add supports for Conv3D, Pool3D, ELU, ReverseSequence
- fix ArgMax, Permute, Scale, BinaryOp, Slice, SliceTf
- OpenCL
- add half transform in CPU
- add broadcast supports for binary
- optimize Conv2D, Reshape, Eltwise, Gemm, etc.
- OpenGL
- add sub, real div supports for binary
- add supports for unary
- optimize Conv2D, Reshape
- Vulkan
- add max supports for eltwise
- Metal
- fix metallib missing problem
- Train/Quantization
- use express to refactor training codes
2019-09-26 21:02:07 +08:00
|
|
|
|
2019-06-17 20:10:35 +08:00
|
|
|
static const auto gRegister = []() {
|
- dynamic computation graph (beta)
- add supports (/express)
- add tests
- add benchmarks with it (/benchmark/exprModels)
- Python
- MNN engine and tools were submitted to pip
- available on Windows/macOS/Linux
- Engine/Converter
- add supports for each op benchmarking
- refactor optimizer by separating steps
- CPU
- add supports for Conv3D, Pool3D, ELU, ReverseSequence
- fix ArgMax, Permute, Scale, BinaryOp, Slice, SliceTf
- OpenCL
- add half transform in CPU
- add broadcast supports for binary
- optimize Conv2D, Reshape, Eltwise, Gemm, etc.
- OpenGL
- add sub, real div supports for binary
- add supports for unary
- optimize Conv2D, Reshape
- Vulkan
- add max supports for eltwise
- Metal
- fix metallib missing problem
- Train/Quantization
- use express to refactor training codes
2019-09-26 21:02:07 +08:00
|
|
|
static PoolGrad _c;
|
2019-06-17 20:10:35 +08:00
|
|
|
OpGrad::insert(OpType_Pooling, &_c);
|
|
|
|
|
return true;
|
|
|
|
|
}();
|