Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8771fff3
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8771fff3
编写于
6月 15, 2023
作者:
Z
Zhenghai Zhang
提交者:
GitHub
6月 15, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
static graph autogen code for prior_box (#54508)
上级
ce0c5c27
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
25 addition
and
242 deletion
+25
-242
paddle/fluid/operators/detection/CMakeLists.txt
paddle/fluid/operators/detection/CMakeLists.txt
+0
-2
paddle/fluid/operators/detection/density_prior_box_op.cc
paddle/fluid/operators/detection/density_prior_box_op.cc
+8
-0
paddle/fluid/operators/detection/prior_box_op.cc
paddle/fluid/operators/detection/prior_box_op.cc
+0
-194
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+0
-8
paddle/phi/api/yaml/op_compat.yaml
paddle/phi/api/yaml/op_compat.yaml
+8
-0
paddle/phi/api/yaml/ops.yaml
paddle/phi/api/yaml/ops.yaml
+9
-0
paddle/phi/ops/compat/prior_box_sig.cc
paddle/phi/ops/compat/prior_box_sig.cc
+0
-38
未找到文件。
paddle/fluid/operators/detection/CMakeLists.txt
浏览文件 @
8771fff3
...
...
@@ -34,11 +34,9 @@ detection_library(density_prior_box_op SRCS density_prior_box_op.cc
if
(
WITH_XPU
)
detection_library
(
iou_similarity_op SRCS iou_similarity_op.cc
iou_similarity_op_xpu.cc
)
detection_library
(
prior_box_op SRCS prior_box_op.cc
)
else
()
detection_library
(
iou_similarity_op SRCS iou_similarity_op.cc
iou_similarity_op.cu
)
detection_library
(
prior_box_op SRCS prior_box_op.cc
)
endif
()
detection_library
(
bipartite_match_op SRCS bipartite_match_op.cc
)
...
...
paddle/fluid/operators/detection/density_prior_box_op.cc
浏览文件 @
8771fff3
...
...
@@ -268,3 +268,11 @@ PD_REGISTER_STRUCT_KERNEL(density_prior_box,
ops
::
DensityPriorBoxOpKernel
,
float
,
double
)
{}
REGISTER_OP_KERNEL
(
prior_box
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
PriorBoxOpKernel
<
float
>
,
ops
::
PriorBoxOpKernel
<
double
>
,
ops
::
PriorBoxOpKernel
<
uint8_t
>
,
ops
::
PriorBoxOpKernel
<
int8_t
>
);
paddle/fluid/operators/detection/prior_box_op.cc
已删除
100644 → 0
浏览文件 @
ce0c5c27
/* Copyright (c) 2016 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. */
#include "paddle/fluid/operators/detection/prior_box_op.h"
#include <string>
#include "paddle/fluid/framework/convert_utils.h"
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/phi/infermeta/binary.h"
namespace
paddle
{
namespace
operators
{
class
PriorBoxOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
protected:
phi
::
KernelKey
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
input_input_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
return
phi
::
KernelKey
(
input_input_type
,
ctx
.
GetPlace
());
}
};
class
PriorBoxOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddInput
(
"Input"
,
"(Tensor, default Tensor<float>), "
"the input feature data of PriorBoxOp, The layout is NCHW."
);
AddInput
(
"Image"
,
"(Tensor, default Tensor<float>), "
"the input image data of PriorBoxOp, The layout is NCHW."
);
AddOutput
(
"Boxes"
,
"(Tensor, default Tensor<float>), the output prior boxes of "
"PriorBoxOp. The layout is [H, W, num_priors, 4]. "
"H is the height of input, W is the width of input, num_priors "
"is the box count of each position."
);
AddOutput
(
"Variances"
,
"(Tensor, default Tensor<float>), the expanded variances of "
"PriorBoxOp. The layout is [H, W, num_priors, 4]. "
"H is the height of input, W is the width of input, num_priors "
"is the box count of each position."
);
AddAttr
<
std
::
vector
<
float
>>
(
"min_sizes"
,
"(vector<float>) List of min sizes "
"of generated prior boxes."
)
.
AddCustomChecker
([](
const
std
::
vector
<
float
>&
min_sizes
)
{
PADDLE_ENFORCE_GT
(
min_sizes
.
size
(),
0
,
platform
::
errors
::
InvalidArgument
(
"Size of min_sizes must be "
"at least 1."
));
for
(
size_t
i
=
0
;
i
<
min_sizes
.
size
();
++
i
)
{
PADDLE_ENFORCE_GT
(
min_sizes
[
i
],
0.0
,
platform
::
errors
::
OutOfRange
(
"min_sizes[%d] must be larger "
"than 0. But received: min_sizes[%d] is %f."
,
i
,
i
,
min_sizes
[
i
]));
}
});
AddAttr
<
std
::
vector
<
float
>>
(
"max_sizes"
,
"(vector<float>) List of max sizes of generated prior boxes."
)
.
SetDefault
(
std
::
vector
<
float
>
{});
AddAttr
<
std
::
vector
<
float
>>
(
"aspect_ratios"
,
"(vector<float>) List of aspect ratios of generated prior boxes."
);
AddAttr
<
std
::
vector
<
float
>>
(
"variances"
,
"(vector<float>) List of variances to be encoded in prior boxes."
)
.
AddCustomChecker
([](
const
std
::
vector
<
float
>&
variances
)
{
PADDLE_ENFORCE_EQ
(
variances
.
size
(),
4
,
platform
::
errors
::
InvalidArgument
(
"The length of variance must "
"be 4. But received: variances' length is %d."
,
variances
.
size
()));
for
(
size_t
i
=
0
;
i
<
variances
.
size
();
++
i
)
{
PADDLE_ENFORCE_GT
(
variances
[
i
],
0.0
,
platform
::
errors
::
OutOfRange
(
"variance[%d] must be greater "
"than 0. But received: variance[%d] = %f"
,
i
,
i
,
variances
[
i
]));
}
});
AddAttr
<
bool
>
(
"flip"
,
"(bool) Whether to flip aspect ratios."
)
.
SetDefault
(
true
);
AddAttr
<
bool
>
(
"clip"
,
"(bool) Whether to clip out-of-boundary boxes."
)
.
SetDefault
(
true
);
AddAttr
<
float
>
(
"step_w"
,
"Prior boxes step across width, 0.0 for auto calculation."
)
.
SetDefault
(
0.0
)
.
AddCustomChecker
([](
const
float
&
step_w
)
{
PADDLE_ENFORCE_GE
(
step_w
,
0.0
,
platform
::
errors
::
InvalidArgument
(
"step_w should be larger "
"than 0. But received: step_w = %f."
,
step_w
));
});
AddAttr
<
float
>
(
"step_h"
,
"Prior boxes step across height, 0.0 for auto calculation."
)
.
SetDefault
(
0.0
)
.
AddCustomChecker
([](
const
float
&
step_h
)
{
PADDLE_ENFORCE_GE
(
step_h
,
0.0
,
platform
::
errors
::
InvalidArgument
(
"step_h should be larger "
"than 0. But received: step_h = %f."
,
step_h
));
});
AddAttr
<
float
>
(
"offset"
,
"(float) "
"Prior boxes center offset."
)
.
SetDefault
(
0.5
);
AddAttr
<
bool
>
(
"min_max_aspect_ratios_order"
,
"(bool) If set True, the output prior box is in order of"
"[min, max, aspect_ratios], which is consistent with Caffe."
"Please note, this order affects the weights order of convolution layer"
"followed by and does not affect the final detection results."
)
.
SetDefault
(
false
);
AddAttr
<
bool
>
(
"use_mkldnn"
,
"(bool, default false) Only used in mkldnn kernel"
)
.
SetDefault
(
false
);
AddAttr
<
bool
>
(
"use_quantizer"
,
"(bool, default false) "
"This parameter is no longer used. Use 'mkldnn_data_type' instead."
)
.
SetDefault
(
false
);
AddAttr
<
std
::
string
>
(
"mkldnn_data_type"
,
"(string, default
\"
float32
\"
). Data type of mkldnn kernel"
)
.
SetDefault
(
"float32"
)
.
InEnum
({
"float32"
,
"int8"
,
"bfloat16"
});
AddComment
(
R"DOC(
Prior box operator
Generate prior boxes for SSD(Single Shot MultiBox Detector) algorithm.
Each position of the input produce N prior boxes, N is determined by
the count of min_sizes, max_sizes and aspect_ratios, The size of the
box is in range(min_size, max_size) interval, which is generated in
sequence according to the aspect_ratios.
Please get more information from the following papers:
https://arxiv.org/abs/1512.02325.
)DOC"
);
}
};
}
// namespace operators
}
// namespace paddle
DECLARE_INFER_SHAPE_FUNCTOR
(
prior_box
,
PriorBoxInferShapeFunctor
,
PD_INFER_META
(
phi
::
PriorBoxInferMeta
));
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
prior_box
,
ops
::
PriorBoxOp
,
ops
::
PriorBoxOpMaker
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
PriorBoxInferShapeFunctor
);
REGISTER_OP_KERNEL
(
prior_box
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
PriorBoxOpKernel
<
float
>
,
ops
::
PriorBoxOpKernel
<
double
>
,
ops
::
PriorBoxOpKernel
<
uint8_t
>
,
ops
::
PriorBoxOpKernel
<
int8_t
>
);
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
8771fff3
...
...
@@ -727,14 +727,6 @@
param
:
[
x
,
kernel_size
,
strides
,
paddings
,
ceil_mode
,
exclusive
,
data_format
,
pooling_type
,
global_pooling
,
adaptive
,
padding_algorithm
]
backward
:
pool3d_grad
-
op
:
prior_box
args
:
(Tensor input, Tensor image, float[] min_sizes, float[] max_sizes = {}, float[] aspect_ratios = {}, float[] variances = {}, bool flip=true, bool clip=true, float step_w=0.0, float step_h=0.0, float offset=0.5, bool min_max_aspect_ratios_order=false)
output
:
Tensor(out), Tensor(var)
infer_meta
:
func
:
PriorBoxInferMeta
kernel
:
func
:
prior_box
-
op
:
prod
args
:
(Tensor x, IntArray dims, bool keep_dim, bool reduce_all)
output
:
Tensor
...
...
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
8771fff3
...
...
@@ -1984,6 +1984,14 @@
extra
:
attrs
:
[
bool use_mkldnn = false
,
str mkldnn_data_type = "float32"
,
bool is_test = false
]
-
op
:
prior_box
inputs
:
{
input
:
Input
,
image
:
Image
}
outputs
:
{
out
:
Boxes
,
var
:
Variances
}
extra
:
attrs
:
[
bool use_mkldnn = false
,
bool use_quantizer = false
,
str mkldnn_data_type = "float32"
]
-
op
:
prod (reduce_prod)
backward
:
prod_grad (reduce_prod_grad)
inputs
:
...
...
paddle/phi/api/yaml/ops.yaml
浏览文件 @
8771fff3
...
...
@@ -1803,6 +1803,15 @@
data_type
:
x
backward
:
prelu_grad
-
op
:
prior_box
args
:
(Tensor input, Tensor image, float[] min_sizes, float[] max_sizes = {}, float[] aspect_ratios = {}, float[] variances = {}, bool flip=true, bool clip=true, float step_w=0.0, float step_h=0.0, float offset=0.5, bool min_max_aspect_ratios_order=false)
output
:
Tensor(out), Tensor(var)
infer_meta
:
func
:
PriorBoxInferMeta
kernel
:
func
:
prior_box
data_type
:
input
-
op
:
put_along_axis
args
:
(Tensor arr, Tensor indices, Tensor values, int axis, str reduce = "assign")
output
:
Tensor(out)
...
...
paddle/phi/ops/compat/prior_box_sig.cc
已删除
100644 → 0
浏览文件 @
ce0c5c27
// Copyright (c) 2022 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.
#include "paddle/phi/core/compat/op_utils.h"
namespace
phi
{
KernelSignature
PriorBoxOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
UNUSED
)
{
return
KernelSignature
(
"prior_box"
,
{
"Input"
,
"Image"
},
{
"min_sizes"
,
"max_sizes"
,
"aspect_ratios"
,
"variances"
,
"flip"
,
"clip"
,
"step_w"
,
"step_h"
,
"offset"
,
"min_max_aspect_ratios_order"
},
{
"Boxes"
,
"Variances"
});
}
}
// namespace phi
PD_REGISTER_ARG_MAPPING_FN
(
prior_box
,
phi
::
PriorBoxOpArgumentMapping
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录