Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
a96372b1
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a96372b1
编写于
10月 13, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of github.com:baidu/Paddle into feature/implenment_infer_var_type
上级
1b1cb44f
9165235a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
119 addition
and
0 deletion
+119
-0
paddle/framework/CMakeLists.txt
paddle/framework/CMakeLists.txt
+2
-0
paddle/framework/selected_rows.cc
paddle/framework/selected_rows.cc
+16
-0
paddle/framework/selected_rows.h
paddle/framework/selected_rows.h
+54
-0
paddle/framework/selected_rows_test.cc
paddle/framework/selected_rows_test.cc
+47
-0
未找到文件。
paddle/framework/CMakeLists.txt
浏览文件 @
a96372b1
...
...
@@ -56,3 +56,5 @@ cc_test(tensor_array_test SRCS tensor_array_test.cc DEPS tensor_array place)
cc_test
(
var_type_inference_test SRCS var_type_inference_test.cc DEPS op_registry
proto_desc
)
cc_library
(
selected_rows SRCS selected_rows.cc DEPS tensor
)
cc_test
(
selected_rows_test SRCS selected_rows_test.cc DEPS selected_rows
)
paddle/framework/selected_rows.cc
0 → 100644
浏览文件 @
a96372b1
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
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/framework/selected_rows.h"
namespace
paddle
{
namespace
framework
{}
// namespace framework
}
// namespace paddle
paddle/framework/selected_rows.h
0 → 100644
浏览文件 @
a96372b1
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
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. */
#pragma once
#include "paddle/framework/tensor.h"
namespace
paddle
{
namespace
framework
{
class
SelectedRows
{
public:
SelectedRows
(
const
std
::
vector
<
int64_t
>&
rows
,
const
int64_t
&
height
)
:
rows_
(
rows
),
height_
(
height
)
{
value_
.
reset
(
new
Tensor
());
}
SelectedRows
()
{
value_
.
reset
(
new
Tensor
());
}
platform
::
Place
place
()
const
{
return
value_
->
place
();
}
const
Tensor
&
value
()
const
{
return
*
value_
;
}
Tensor
*
mutable_value
()
{
return
value_
.
get
();
}
int64_t
height
()
const
{
return
height_
;
}
void
set_height
(
int64_t
height
)
{
height_
=
height
;
}
const
std
::
vector
<
int64_t
>&
rows
()
const
{
return
rows_
;
}
void
set_rows
(
const
std
::
vector
<
int64_t
>&
rows
)
{
rows_
=
rows
;
}
DDim
GetCompleteDims
()
const
{
std
::
vector
<
int64_t
>
dims
=
vectorize
(
value_
->
dims
());
dims
[
0
]
=
height_
;
return
make_ddim
(
dims
);
}
private:
std
::
vector
<
int64_t
>
rows_
;
std
::
unique_ptr
<
Tensor
>
value_
{
nullptr
};
int64_t
height_
;
};
}
// namespace framework
}
// namespace paddle
paddle/framework/selected_rows_test.cc
0 → 100644
浏览文件 @
a96372b1
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
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/framework/selected_rows.h"
#include "gtest/gtest.h"
namespace
paddle
{
namespace
framework
{
class
SelectedRowsTester
:
public
::
testing
::
Test
{
public:
virtual
void
SetUp
()
override
{
std
::
vector
<
int64_t
>
rows
{
0
,
4
,
7
};
int64_t
height
=
10
;
int64_t
row_numel
=
100
;
selected_rows_
.
reset
(
new
SelectedRows
(
rows
,
height
));
Tensor
*
value
=
selected_rows_
->
mutable_value
();
value
->
mutable_data
<
float
>
(
make_ddim
({
static_cast
<
int64_t
>
(
rows
.
size
()),
row_numel
}),
place_
);
}
protected:
platform
::
CPUPlace
place_
;
std
::
unique_ptr
<
SelectedRows
>
selected_rows_
{
nullptr
};
};
TEST_F
(
SelectedRowsTester
,
height
)
{
ASSERT_EQ
(
selected_rows_
->
height
(),
10
);
}
TEST_F
(
SelectedRowsTester
,
dims
)
{
ASSERT_EQ
(
selected_rows_
->
value
().
dims
(),
make_ddim
({
3
,
100
}));
}
TEST_F
(
SelectedRowsTester
,
complete_dims
)
{
ASSERT_EQ
(
selected_rows_
->
GetCompleteDims
(),
make_ddim
({
10
,
100
}));
}
}
// namespace framework
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录