Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yushenjjy
Paddle
提交
3f2a6ab6
P
Paddle
项目概览
yushenjjy
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3f2a6ab6
编写于
10月 14, 2020
作者:
H
hutuxian
提交者:
GitHub
10月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix error msg (#27887)
上级
426de255
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
27 addition
and
7 deletion
+27
-7
paddle/fluid/operators/pull_box_sparse_op.cc
paddle/fluid/operators/pull_box_sparse_op.cc
+12
-7
python/paddle/fluid/tests/unittests/test_boxps.py
python/paddle/fluid/tests/unittests/test_boxps.py
+15
-0
未找到文件。
paddle/fluid/operators/pull_box_sparse_op.cc
浏览文件 @
3f2a6ab6
...
...
@@ -21,10 +21,14 @@ class PullBoxSparseOp : public framework::OperatorWithKernel {
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE_GE
(
ctx
->
Inputs
(
"Ids"
).
size
(),
1UL
,
"Inputs(Ids) of PullBoxSparseOp should not be empty."
);
PADDLE_ENFORCE_GE
(
ctx
->
Outputs
(
"Out"
).
size
(),
1UL
,
"Outputs(Out) of PullBoxSparseOp should not be empty."
);
PADDLE_ENFORCE_GE
(
ctx
->
Inputs
(
"Ids"
).
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"Inputs(Ids) of PullBoxSparseOp should not be empty."
));
PADDLE_ENFORCE_GE
(
ctx
->
Outputs
(
"Out"
).
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"Outputs(Out) of PullBoxSparseOp should not be empty."
));
auto
hidden_size
=
static_cast
<
int64_t
>
(
ctx
->
Attrs
().
Get
<
int
>
(
"size"
));
auto
all_ids_dim
=
ctx
->
GetInputsDim
(
"Ids"
);
const
size_t
n_ids
=
all_ids_dim
.
size
();
...
...
@@ -34,9 +38,10 @@ class PullBoxSparseOp : public framework::OperatorWithKernel {
const
auto
ids_dims
=
all_ids_dim
[
i
];
int
ids_rank
=
ids_dims
.
size
();
PADDLE_ENFORCE_EQ
(
ids_dims
[
ids_rank
-
1
],
1
,
platform
::
errors
::
InvalidArgument
(
"Shape error in %lu id, the last dimension of the "
"'Ids' tensor must be 1."
,
i
);
i
)
);
auto
out_dim
=
framework
::
vectorize
(
framework
::
slice_ddim
(
ids_dims
,
0
,
ids_rank
-
1
));
out_dim
.
push_back
(
hidden_size
);
...
...
python/paddle/fluid/tests/unittests/test_boxps.py
浏览文件 @
3f2a6ab6
...
...
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid.layers
as
layers
import
numpy
as
np
...
...
@@ -87,5 +88,19 @@ class TestRunCmd(unittest.TestCase):
self
.
assertTrue
(
ret2
==
0
)
class
TestPullBoxSparseOP
(
unittest
.
TestCase
):
""" TestCases for _pull_box_sparse op"""
def
test_pull_box_sparse_op
(
self
):
paddle
.
enable_static
()
program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
program
):
x
=
fluid
.
layers
.
data
(
name
=
'x'
,
shape
=
[
1
],
dtype
=
'int64'
,
lod_level
=
0
)
y
=
fluid
.
layers
.
data
(
name
=
'y'
,
shape
=
[
1
],
dtype
=
'int64'
,
lod_level
=
0
)
emb_x
,
emb_y
=
_pull_box_sparse
([
x
,
y
],
size
=
1
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录