提交 fa10f03f 编写于 作者: W wanghaox

update code

上级 25a01932
...@@ -35,6 +35,7 @@ class IOUSimilarityOp : public framework::OperatorWithKernel { ...@@ -35,6 +35,7 @@ class IOUSimilarityOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ(y_dims.size(), 2UL, "The rank of Input(Y) must be 2."); PADDLE_ENFORCE_EQ(y_dims.size(), 2UL, "The rank of Input(Y) must be 2.");
PADDLE_ENFORCE_EQ(y_dims[1], 4UL, "The shape of Y is [M, 4]"); PADDLE_ENFORCE_EQ(y_dims[1], 4UL, "The shape of Y is [M, 4]");
ctx->ShareLoD("X", /*->*/ "Out");
ctx->SetOutputDim("Out", framework::make_ddim({x_dims[0], y_dims[0]})); ctx->SetOutputDim("Out", framework::make_ddim({x_dims[0], y_dims[0]}));
} }
}; };
...@@ -47,20 +48,23 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -47,20 +48,23 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker {
"(LoDTensor, default LoDTensor<float>) " "(LoDTensor, default LoDTensor<float>) "
"Box list X is a 2-D LoDTensor with shape [N, 4] holds N boxes, " "Box list X is a 2-D LoDTensor with shape [N, 4] holds N boxes, "
"each box is represented as [xmin, ymin, xmax, ymax], " "each box is represented as [xmin, ymin, xmax, ymax], "
"the shape of X is [N, 4]. [xmin, ymin] is the lower left " "the shape of X is [N, 4]. [xmin, ymin] is the left top "
"coordinate of the box, and [xmax, ymax] is the right upper " "coordinate of the box if the input is image feature map, they "
"coordinate of the box.This tensor can contain LoD information " "are close to the origin of the coordinate system. "
"to represent a batch of inputs. One instance of this batch can " "[xmax, ymax] is the right bottom coordinate of the box. "
"contain different numbers of entities."); "This tensor can contain LoD information to represent a batch "
"of inputs. One instance of this batch can contain different "
"numbers of entities.");
AddInput("Y", AddInput("Y",
"(Tensor, default Tensor<float>) " "(Tensor, default Tensor<float>) "
"Box list Y holds M boxes, each box is " "Box list Y holds M boxes, each box is represented as "
"represented as [xmin, ymin, xmax, ymax], the shape of X is [N, " "[xmin, ymin, xmax, ymax], the shape of X is [N, 4]. "
"4]. [xmin, ymin] is the lower left coordinate of the box, and " "[xmin, ymin] is the left top coordinate of the box if the "
"[xmax, ymax] is the right upper coordinate of the box."); "input is image feature map, and [xmax, ymax] is the right "
"bottom coordinate of the box.");
AddOutput("Out", AddOutput("Out",
"(LoDTensor or Tensor, the lod is same as input X) The output of " "(LoDTensor, the lod is same as input X) The output of "
"iou_similarity op, a tensor with shape [N, M] " "iou_similarity op, a tensor with shape [N, M] "
"representing pairwise iou scores."); "representing pairwise iou scores.");
...@@ -68,8 +72,8 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -68,8 +72,8 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker {
IOU Similarity Operator. IOU Similarity Operator.
Computes intersection-over-union (IOU) between two box lists. Computes intersection-over-union (IOU) between two box lists.
Box list 'X' should be a LoDTensor and 'Y' is a common Tensor, Box list 'X' should be a LoDTensor and 'Y' is a common Tensor,
boxes in 'Y' are shared by all input images. boxes in 'Y' are shared by all instance of the batched inputs of X.
Given two box A and B, the calculation of IOU is as follows: Given two boxes A and B, the calculation of IOU is as follows:
$$ $$
IOU(A, B) = IOU(A, B) =
......
...@@ -83,8 +83,6 @@ class IOUSimilarityKernel : public framework::OpKernel<T> { ...@@ -83,8 +83,6 @@ class IOUSimilarityKernel : public framework::OpKernel<T> {
platform::ForRange<DeviceContext> for_range( platform::ForRange<DeviceContext> for_range(
static_cast<const DeviceContext&>(ctx.device_context()), x_n); static_cast<const DeviceContext&>(ctx.device_context()), x_n);
for_range(functor); for_range(functor);
out->set_lod(in_x->lod());
} }
}; // namespace operators }; // namespace operators
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册