2019-04-17 10:49:11 +08:00
|
|
|
//
|
|
|
|
// VulkanInterp.cpp
|
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2019/01/31.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "VulkanInterp.hpp"
|
|
|
|
|
|
|
|
namespace MNN {
|
|
|
|
|
|
|
|
VulkanInterp::VulkanInterp(const Op* op, Backend* bn) : VulkanResize(bn, 1, 1, op->main_as_Interp()->resizeType()) {
|
|
|
|
auto interpParam = op->main_as_Interp();
|
|
|
|
mAlignCorners = interpParam->alignCorners();
|
|
|
|
}
|
|
|
|
|
|
|
|
VulkanInterp::~VulkanInterp() {
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrorCode VulkanInterp::onEncode(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs,
|
|
|
|
const VulkanCommandPool::Buffer* cmdBuffer) {
|
|
|
|
auto input = inputs[0];
|
|
|
|
auto output = outputs[0];
|
|
|
|
auto& ib = input->buffer();
|
|
|
|
auto& ob = output->buffer();
|
|
|
|
|
|
|
|
int iw = ib.dim[3].extent, ow = ob.dim[3].extent;
|
|
|
|
int ih = ib.dim[2].extent, oh = ob.dim[2].extent;
|
|
|
|
|
|
|
|
float xScale = 1;
|
|
|
|
float yScale = 1;
|
|
|
|
if (mAlignCorners) {
|
|
|
|
yScale = (float)(ih - 1) / (float)(oh - 1);
|
|
|
|
xScale = (float)(iw - 1) / (float)(ow - 1);
|
|
|
|
} else {
|
|
|
|
yScale = (float)(ih) / (float)(oh);
|
|
|
|
xScale = (float)(iw) / (float)(ow);
|
|
|
|
}
|
|
|
|
|
|
|
|
encodeImpl(input, output, xScale, yScale, cmdBuffer);
|
|
|
|
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
class VulkanInterpCreator : public VulkanBackend::Creator {
|
|
|
|
public:
|
- 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
|
|
|
virtual VulkanBasicExecution* onCreate(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs, const MNN::Op* op, Backend* bn) const override {
|
2019-04-17 10:49:11 +08:00
|
|
|
return new VulkanInterp(op, bn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool gResistor = []() {
|
|
|
|
VulkanBackend::addCreator(OpType_Interp, new VulkanInterpCreator);
|
|
|
|
return true;
|
|
|
|
}();
|
|
|
|
|
|
|
|
} // namespace MNN
|