From 00a81db2880cabee43188881336627aa2475d21a Mon Sep 17 00:00:00 2001 From: Huie <32028380+Huie1228@users.noreply.github.com> Date: Mon, 5 Aug 2019 12:57:40 +0800 Subject: [PATCH] 1.add flatten2 kernel not implemented. 2.add density_prior_box kernel not implemented (#1781) --- src/framework/load_ops.h | 7 +++- src/operators/flatten2_op.cpp | 32 +++++++++++++++ src/operators/flatten2_op.h | 34 ++++++++++++++++ .../cl/cl_kernel/density_prior_box_kernel.cl | 9 +++++ .../kernel/cl/cl_kernel/flatten2_kernel.cl | 8 ++++ .../kernel/cl/density_prior_box_kernel.cpp | 39 +++++++++++++++++++ src/operators/kernel/cl/flatten2_kernel.cpp | 37 ++++++++++++++++++ src/operators/kernel/flatten2_kernel.h | 28 +++++++++++++ src/operators/prior_box_op.cpp | 3 ++ tools/op.cmake | 6 +++ 10 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 src/operators/flatten2_op.cpp create mode 100644 src/operators/flatten2_op.h create mode 100644 src/operators/kernel/cl/cl_kernel/density_prior_box_kernel.cl create mode 100644 src/operators/kernel/cl/cl_kernel/flatten2_kernel.cl create mode 100644 src/operators/kernel/cl/density_prior_box_kernel.cpp create mode 100644 src/operators/kernel/cl/flatten2_kernel.cpp create mode 100644 src/operators/kernel/flatten2_kernel.h diff --git a/src/framework/load_ops.h b/src/framework/load_ops.h index 3beae9eddd..2738e2470e 100644 --- a/src/framework/load_ops.h +++ b/src/framework/load_ops.h @@ -127,6 +127,9 @@ LOAD_OP2(transpose2, CPU, GPU_CL); #ifdef PRIORBOX_OP LOAD_OP2(prior_box, CPU, GPU_CL); #endif +#ifdef DENSITY_PRIORBOX_OP +LOAD_OP2(density_prior_box, CPU, GPU_CL); +#endif #ifdef FUSION_CONVADDRELU_OP LOAD_OP3(fusion_conv_add_relu, CPU, GPU_CL, FPGA); LOAD_FUSION_MATCHER(fusion_conv_add_relu); @@ -158,7 +161,9 @@ LOAD_OP1(prelu, CPU); #endif #ifdef FLATTEN_OP LOAD_OP1(flatten, CPU); -LOAD_OP1(flatten2, CPU); +#endif +#ifdef FLATTEN2_OP +LOAD_OP2(flatten2, CPU, GPU_CL); #endif #ifdef FUSION_CONVBNADDRELU_OP LOAD_OP3(fusion_conv_bn_add_relu, CPU, GPU_CL, FPGA); diff --git a/src/operators/flatten2_op.cpp b/src/operators/flatten2_op.cpp new file mode 100644 index 0000000000..99addf0fdb --- /dev/null +++ b/src/operators/flatten2_op.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#ifdef FLATTEN2_OP + +#include "operators/flatten2_op.h" +namespace paddle_mobile { +namespace operators { +template +void Flatten2Op::InferShape() const {} + +} // namespace operators +} // namespace paddle_mobile + +namespace ops = paddle_mobile::operators; + +#ifdef PADDLE_MOBILE_CL +REGISTER_OPERATOR_CL(flatten2, ops::Flatten2Op); +#endif + +#endif diff --git a/src/operators/flatten2_op.h b/src/operators/flatten2_op.h new file mode 100644 index 0000000000..9c08e9c335 --- /dev/null +++ b/src/operators/flatten2_op.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#ifdef FLATTEN2_OP + +#pragma once + +#include +#include + +#include "framework/operator.h" +#include "operators/kernel/flatten2_kernel.h" +#include "operators/op_param.h" + +namespace paddle_mobile { +namespace operators { + +DECLARE_OPERATOR(Flatten2, FlattenParam, Flatten2Kernel); + +} // namespace operators +} // namespace paddle_mobile + +#endif diff --git a/src/operators/kernel/cl/cl_kernel/density_prior_box_kernel.cl b/src/operators/kernel/cl/cl_kernel/density_prior_box_kernel.cl new file mode 100644 index 0000000000..9d12c0c5f2 --- /dev/null +++ b/src/operators/kernel/cl/cl_kernel/density_prior_box_kernel.cl @@ -0,0 +1,9 @@ + + + + + + +__kernel void density_prior_box(){ + +} \ No newline at end of file diff --git a/src/operators/kernel/cl/cl_kernel/flatten2_kernel.cl b/src/operators/kernel/cl/cl_kernel/flatten2_kernel.cl new file mode 100644 index 0000000000..c7b688d8ae --- /dev/null +++ b/src/operators/kernel/cl/cl_kernel/flatten2_kernel.cl @@ -0,0 +1,8 @@ + + + + + +__kernel void flatten2(){ + +} \ No newline at end of file diff --git a/src/operators/kernel/cl/density_prior_box_kernel.cpp b/src/operators/kernel/cl/density_prior_box_kernel.cpp new file mode 100644 index 0000000000..e182c0598c --- /dev/null +++ b/src/operators/kernel/cl/density_prior_box_kernel.cpp @@ -0,0 +1,39 @@ +/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#ifdef DENSITY_PRIORBOX_OP + +#include + +namespace paddle_mobile { +namespace operators { + +template <> +bool DensityPriorBoxKernel::Init( + paddle_mobile::operators::DensityPriorBoxParam + *param) { + this->cl_helper_.AddKernel("density_prior_box", + "density_prior_box_kernel.cl"); + return true; +} + +template <> +void DensityPriorBoxKernel::Compute( + const paddle_mobile::operators::DensityPriorBoxParam + ¶m) {} + +} // namespace operators +} // namespace paddle_mobile + +#endif diff --git a/src/operators/kernel/cl/flatten2_kernel.cpp b/src/operators/kernel/cl/flatten2_kernel.cpp new file mode 100644 index 0000000000..c1b60e673d --- /dev/null +++ b/src/operators/kernel/cl/flatten2_kernel.cpp @@ -0,0 +1,37 @@ +/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#ifdef FLATTEN2_OP + +#include "operators/kernel/flatten2_kernel.h" + +namespace paddle_mobile { +namespace operators { + +template <> +bool Flatten2Kernel::Init( + paddle_mobile::operators::FlattenParam *param) { + this->cl_helper_.AddKernel("flatten2", "flatten2_kernel.cl"); + return true; +} + +template <> +void Flatten2Kernel::Compute( + const paddle_mobile::operators::FlattenParam + ¶m) {} + +} // namespace operators +} // namespace paddle_mobile + +#endif diff --git a/src/operators/kernel/flatten2_kernel.h b/src/operators/kernel/flatten2_kernel.h new file mode 100644 index 0000000000..78b3e820e6 --- /dev/null +++ b/src/operators/kernel/flatten2_kernel.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +// +// Created by hujie09 on 2019-07-31. +// + +#ifdef FLATTEN2_OP +#include +#include "framework/operator.h" +namespace paddle_mobile { +namespace operators { +DECLARE_KERNEL(Flatten2, FlattenParam) +} +} // namespace paddle_mobile + +#endif // FLATTEN2_KERNEL diff --git a/src/operators/prior_box_op.cpp b/src/operators/prior_box_op.cpp index abef57e2bb..da37273de5 100644 --- a/src/operators/prior_box_op.cpp +++ b/src/operators/prior_box_op.cpp @@ -95,4 +95,7 @@ REGISTER_OPERATOR_CPU(density_prior_box, ops::DensityPriorBoxOp); #ifdef PRIORBOX_OP REGISTER_OPERATOR_CL(prior_box, ops::PriorBoxOp); #endif // PRIORBOX_OP +#ifdef DENSITY_PRIORBOX_OP +REGISTER_OPERATOR_CL(density_prior_box, ops::DensityPriorBoxOp); +#endif // DENSITY_PRIORBOX_OP #endif // PADDLE_MOBILE_CL diff --git a/tools/op.cmake b/tools/op.cmake index b8ea4cb7b7..eb23a5b391 100755 --- a/tools/op.cmake +++ b/tools/op.cmake @@ -237,6 +237,7 @@ if (CON GREATER -1) set(BOXCODER_OP ON) set(MULTICLASSNMS_OP ON) set(FLATTEN_OP ON) + set(FLATTEN2_OP ON) set(SPLIT_OP ON) set(SHAPE_OP ON) @@ -328,6 +329,7 @@ if(NOT FOUND_MATCH) set(BILINEAR_INTERP_OP ON) set(SPLIT_OP ON) set(FLATTEN_OP ON) + set(FLATTEN2_OP ON) set(SHAPE_OP ON) set(ELEMENTWISEMUL_OP ON) set(SUM_OP ON) @@ -555,6 +557,10 @@ if (FLATTEN_OP) add_definitions(-DFLATTEN_OP) endif() +if (FLATTEN2_OP) + add_definitions(-DFLATTEN2_OP) +endif() + if (SPLIT_OP) add_definitions(-DSPLIT_OP) endif() -- GitLab