提交 42706273 编写于 作者: qnqinan's avatar qnqinan

update FPGA support op and related files

上级 b47306cc
...@@ -31,7 +31,7 @@ class FusionConvAddReluOpMatcher : public framework::FusionOpMatcher { ...@@ -31,7 +31,7 @@ class FusionConvAddReluOpMatcher : public framework::FusionOpMatcher {
FusionConvAddReluOpMatcher() { FusionConvAddReluOpMatcher() {
node_ = framework::Node(G_OP_TYPE_CONV); node_ = framework::Node(G_OP_TYPE_CONV);
node_ > std::make_shared<framework::Node>(G_OP_TYPE_ELEMENTWISE_ADD) > node_ > std::make_shared<framework::Node>(G_OP_TYPE_ELEMENTWISE_ADD) >
std::make_shared<framework::Node>(G_OP_TYPE_RELU); std::make_shared<framework::Node>(G_OP_TYPE_RELU);
} }
void FolderNodes( void FolderNodes(
......
...@@ -34,8 +34,8 @@ class FusionDeconvAddMatcher : public framework::FusionOpMatcher { ...@@ -34,8 +34,8 @@ class FusionDeconvAddMatcher : public framework::FusionOpMatcher {
void FolderNodes( void FolderNodes(
framework::Node *node, framework::Node *node,
std::vector<std::shared_ptr<framework::Node>> *removed_nodes) { std::vector<std::shared_ptr<framework::Node>> *removed_nodes) {
node->Folder(node_.Depth(), Type(), node->Folder(node_.Depth(), Type(),
{{G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}}}, removed_nodes); {{G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}}}, removed_nodes);
} }
std::string Type() { return G_OP_TYPE_FUSION_DECONV_ADD; } std::string Type() { return G_OP_TYPE_FUSION_DECONV_ADD; }
...@@ -43,17 +43,17 @@ class FusionDeconvAddMatcher : public framework::FusionOpMatcher { ...@@ -43,17 +43,17 @@ class FusionDeconvAddMatcher : public framework::FusionOpMatcher {
template <typename DeviceType, typename T> template <typename DeviceType, typename T>
class FusionDeconvAddOp : public framework::OperatorWithKernel< class FusionDeconvAddOp : public framework::OperatorWithKernel<
DeviceType, FusionDeconvAddParam<DeviceType>, DeviceType, FusionDeconvAddParam<DeviceType>,
operators::DeconvAddKernel<DeviceType, T>> { operators::DeconvAddKernel<DeviceType, T>> {
public: public:
FusionDeconvAddOp(const string &type, const VariableNameMap &inputs, FusionDeconvAddOp(const string &type, const VariableNameMap &inputs,
const VariableNameMap &outputs, const VariableNameMap &outputs,
const framework::AttributeMap &attrs, const framework::AttributeMap &attrs,
std::shared_ptr<framework::Scope> scope) std::shared_ptr<framework::Scope> scope)
: framework::OperatorWithKernel< : framework::OperatorWithKernel<
DeviceType, FusionDeconvAddParam<DeviceType>, DeviceType, FusionDeconvAddParam<DeviceType>,
operators::DeconvAddKernel<DeviceType, T>>(type, inputs, outputs, operators::DeconvAddKernel<DeviceType, T>>(type, inputs, outputs,
attrs, scope) {} attrs, scope) {}
void InferShape() const { void InferShape() const {
auto input = this->param_.Input(); auto input = this->param_.Input();
......
...@@ -21,7 +21,8 @@ namespace operators {} ...@@ -21,7 +21,8 @@ namespace operators {}
} // namespace paddle_mobile } // namespace paddle_mobile
namespace ops = paddle_mobile::operators; namespace ops = paddle_mobile::operators;
REGISTER_FUSION_MATCHER(fusion_deconv_add_relu, ops::FusionDeconvAddReluMatcher); REGISTER_FUSION_MATCHER(fusion_deconv_add_relu,
ops::FusionDeconvAddReluMatcher);
#ifdef PADDLE_MOBILE_CPU #ifdef PADDLE_MOBILE_CPU
#endif #endif
#ifdef PADDLE_MOBILE_MALI_GPU #ifdef PADDLE_MOBILE_MALI_GPU
......
...@@ -29,32 +29,33 @@ class FusionDeconvAddReluMatcher : public framework::FusionOpMatcher { ...@@ -29,32 +29,33 @@ class FusionDeconvAddReluMatcher : public framework::FusionOpMatcher {
FusionDeconvAddReluMatcher() { FusionDeconvAddReluMatcher() {
node_ = framework::Node(G_OP_TYPE_CONV_TRANSPOSE); node_ = framework::Node(G_OP_TYPE_CONV_TRANSPOSE);
node_ > std::make_shared<framework::Node>(G_OP_TYPE_ELEMENTWISE_ADD) > node_ > std::make_shared<framework::Node>(G_OP_TYPE_ELEMENTWISE_ADD) >
std::make_shared<framework::Node>(G_OP_TYPE_RELU); std::make_shared<framework::Node>(G_OP_TYPE_RELU);
} }
void FolderNodes( void FolderNodes(
framework::Node *node, framework::Node *node,
std::vector<std::shared_ptr<framework::Node>> *removed_nodes) { std::vector<std::shared_ptr<framework::Node>> *removed_nodes) {
node->Folder(node_.Depth(), Type(), node->Folder(node_.Depth(), Type(),
{{G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}}}, removed_nodes); {{G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}}}, removed_nodes);
} }
std::string Type() { return G_OP_TYPE_FUSION_DECONV_ADD_RELU; } std::string Type() { return G_OP_TYPE_FUSION_DECONV_ADD_RELU; }
}; };
template <typename DeviceType, typename T> template <typename DeviceType, typename T>
class FusionDeconvAddReluOp : public framework::OperatorWithKernel< class FusionDeconvAddReluOp
DeviceType, FusionDeconvAddReluParam<DeviceType>, : public framework::OperatorWithKernel<
operators::DeconvAddReluKernel<DeviceType, T>> { DeviceType, FusionDeconvAddReluParam<DeviceType>,
operators::DeconvAddReluKernel<DeviceType, T>> {
public: public:
FusionDeconvAddReluOp(const string &type, const VariableNameMap &inputs, FusionDeconvAddReluOp(const string &type, const VariableNameMap &inputs,
const VariableNameMap &outputs, const VariableNameMap &outputs,
const framework::AttributeMap &attrs, const framework::AttributeMap &attrs,
std::shared_ptr<framework::Scope> scope) std::shared_ptr<framework::Scope> scope)
: framework::OperatorWithKernel< : framework::OperatorWithKernel<
DeviceType, FusionDeconvAddReluParam<DeviceType>, DeviceType, FusionDeconvAddReluParam<DeviceType>,
operators::DeconvAddReluKernel<DeviceType, T>>(type, inputs, outputs, operators::DeconvAddReluKernel<DeviceType, T>>(
attrs, scope) {} type, inputs, outputs, attrs, scope) {}
void InferShape() const { void InferShape() const {
auto input = this->param_.Input(); auto input = this->param_.Input();
......
...@@ -22,7 +22,8 @@ namespace paddle_mobile { ...@@ -22,7 +22,8 @@ namespace paddle_mobile {
namespace operators { namespace operators {
template <> template <>
bool DeconvAddReluKernel<FPGA, float>::Init(FusionDeconvAddReluParam<FPGA> *param) { bool DeconvAddReluKernel<FPGA, float>::Init(
FusionDeconvAddReluParam<FPGA> *param) {
return true; return true;
} }
......
...@@ -25,8 +25,9 @@ bool Transpose2Kernel<FPGA, float>::Init(Transpose2Param<FPGA> *param) { ...@@ -25,8 +25,9 @@ bool Transpose2Kernel<FPGA, float>::Init(Transpose2Param<FPGA> *param) {
} }
template <> template <>
void Transpose2Kernel<FPGA, float>::Compute(const Transpose2Param<FPGA> &param) { void Transpose2Kernel<FPGA, float>::Compute(
//Transpose2Compute<float>(param); const Transpose2Param<FPGA> &param) {
// Transpose2Compute<float>(param);
} }
} // namespace operators } // namespace operators
......
...@@ -2221,9 +2221,9 @@ class ConvTransposeParam : public OpParam { ...@@ -2221,9 +2221,9 @@ class ConvTransposeParam : public OpParam {
const Scope &scope) { const Scope &scope) {
filter_ = FilterFrom<GType>(inputs, scope); filter_ = FilterFrom<GType>(inputs, scope);
input_ = InputFrom<GType>(inputs, scope); input_ = InputFrom<GType>(inputs, scope);
//output_ = OutputFrom<GType>(outputs, scope); // output_ = OutputFrom<GType>(outputs, scope);
if (outputs.count("Output")) { if (outputs.count("Output")) {
output_ = OpParam::OutputFrom<GType>(outputs, scope); output_ = OpParam::OutputFrom<GType>(outputs, scope);
} }
strides_ = GetAttr<vector<int>>("strides", attrs); strides_ = GetAttr<vector<int>>("strides", attrs);
paddings_ = GetAttr<vector<int>>("paddings", attrs); paddings_ = GetAttr<vector<int>>("paddings", attrs);
...@@ -2270,11 +2270,12 @@ template <typename Dtype> ...@@ -2270,11 +2270,12 @@ template <typename Dtype>
class FusionDeconvAddParam : public ConvTransposeParam<Dtype> { class FusionDeconvAddParam : public ConvTransposeParam<Dtype> {
typedef typename DtypeTensorTrait<Dtype>::gtype GType; typedef typename DtypeTensorTrait<Dtype>::gtype GType;
typedef typename DtypeTensorTrait<Dtype>::rtype RType; typedef typename DtypeTensorTrait<Dtype>::rtype RType;
public:
public:
FusionDeconvAddParam(const VariableNameMap &inputs, FusionDeconvAddParam(const VariableNameMap &inputs,
const VariableNameMap &outputs, const AttributeMap &attrs, const VariableNameMap &outputs,
const Scope &scope) const AttributeMap &attrs, const Scope &scope)
:ConvTransposeParam<Dtype>(inputs, outputs, attrs, scope) { : ConvTransposeParam<Dtype>(inputs, outputs, attrs, scope) {
bias_ = OpParam::InputYFrom<GType>(inputs, scope); bias_ = OpParam::InputYFrom<GType>(inputs, scope);
axis_ = OpParam::GetAttr<int>("axis", attrs); axis_ = OpParam::GetAttr<int>("axis", attrs);
output_ = OpParam::OutFrom<GType>(outputs, scope); output_ = OpParam::OutFrom<GType>(outputs, scope);
......
...@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and ...@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifdef SPLIT_OP #ifdef SPLIT_OP
#include <vector>
#include "operators/split_op.h" #include "operators/split_op.h"
#include <vector>
namespace paddle_mobile { namespace paddle_mobile {
namespace operators { namespace operators {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册