Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
69f9cea0
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
69f9cea0
编写于
6月 23, 2020
作者:
H
hong19860320
提交者:
GitHub
6月 23, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] Fix the deps of unit tests (#3807)
上级
db7639ca
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
39 addition
and
7 deletion
+39
-7
cmake/device/xpu.cmake
cmake/device/xpu.cmake
+1
-1
lite/core/arena/framework.cc
lite/core/arena/framework.cc
+23
-3
lite/core/memory.cc
lite/core/memory.cc
+5
-0
lite/core/memory.h
lite/core/memory.h
+5
-0
lite/tests/api/CMakeLists.txt
lite/tests/api/CMakeLists.txt
+5
-3
未找到文件。
cmake/device/xpu.cmake
浏览文件 @
69f9cea0
...
@@ -39,7 +39,7 @@ else()
...
@@ -39,7 +39,7 @@ else()
endif
()
endif
()
find_library
(
XPU_SDK_XPU_RT_FILE NAMES xpurt
find_library
(
XPU_SDK_XPU_RT_FILE NAMES xpurt
PATHS
${
XPU_SDK_ROOT
}
/XTDK/shlib
PATHS
${
XPU_SDK_ROOT
}
/XTDK/
runtime/
shlib
NO_DEFAULT_PATH
)
NO_DEFAULT_PATH
)
if
(
NOT XPU_SDK_XPU_RT_FILE
)
if
(
NOT XPU_SDK_XPU_RT_FILE
)
...
...
lite/core/arena/framework.cc
浏览文件 @
69f9cea0
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
// limitations under the License.
// limitations under the License.
#include "lite/core/arena/framework.h"
#include "lite/core/arena/framework.h"
#include <set>
#include "lite/core/context.h"
#include "lite/core/context.h"
#include "lite/operators/subgraph_op.h"
#include "lite/operators/subgraph_op.h"
...
@@ -22,7 +23,14 @@ namespace arena {
...
@@ -22,7 +23,14 @@ namespace arena {
void
TestCase
::
CreateInstruction
()
{
void
TestCase
::
CreateInstruction
()
{
std
::
shared_ptr
<
lite
::
OpLite
>
op
=
nullptr
;
std
::
shared_ptr
<
lite
::
OpLite
>
op
=
nullptr
;
if
(
place_
.
target
==
TARGET
(
kNPU
)
||
place_
.
target
==
TARGET
(
kXPU
))
{
static
const
std
::
set
<
TargetType
>
subgraph_op_supported_targets
(
{
TARGET
(
kNPU
),
TARGET
(
kXPU
)});
bool
enable_subgraph_op
=
subgraph_op_supported_targets
.
find
(
place_
.
target
)
!=
subgraph_op_supported_targets
.
end
();
#if defined(LITE_WITH_XPU) && !defined(LITE_WITH_XTCL)
enable_subgraph_op
=
false
;
// Use XPU kernel directly if XTCL is disabled.
#endif
if
(
enable_subgraph_op
)
{
// Create a new block desc to wrap the original op desc
// Create a new block desc to wrap the original op desc
int
sub_block_idx
=
0
;
int
sub_block_idx
=
0
;
auto
sub_block_desc
=
new
cpp
::
BlockDesc
();
auto
sub_block_desc
=
new
cpp
::
BlockDesc
();
...
@@ -91,7 +99,8 @@ void TestCase::PrepareInputsForInstruction() {
...
@@ -91,7 +99,8 @@ void TestCase::PrepareInputsForInstruction() {
/// alloc memory and then copy data there.
/// alloc memory and then copy data there.
if
(
param_type
->
type
->
IsTensor
())
{
if
(
param_type
->
type
->
IsTensor
())
{
const
auto
*
shared_tensor
=
scope_
->
FindTensor
(
var
);
const
auto
*
shared_tensor
=
scope_
->
FindTensor
(
var
);
auto
*
target_tensor
=
inst_scope_
->
NewTensor
(
var
);
auto
*
target_tensor
=
inst_scope_
->
LocalVar
(
var
)
->
GetMutable
<
Tensor
>
();
CHECK
(
!
shared_tensor
->
dims
().
empty
())
<<
"shared_tensor is empty yet"
;
CHECK
(
!
shared_tensor
->
dims
().
empty
())
<<
"shared_tensor is empty yet"
;
target_tensor
->
Resize
(
shared_tensor
->
dims
());
target_tensor
->
Resize
(
shared_tensor
->
dims
());
TargetCopy
(
param_type
->
type
->
target
(),
TargetCopy
(
param_type
->
type
->
target
(),
...
@@ -103,7 +112,7 @@ void TestCase::PrepareInputsForInstruction() {
...
@@ -103,7 +112,7 @@ void TestCase::PrepareInputsForInstruction() {
const
auto
*
shared_tensor_array
=
const
auto
*
shared_tensor_array
=
scope_
->
FindVar
(
var
)
->
GetMutable
<
std
::
vector
<
Tensor
>>
();
scope_
->
FindVar
(
var
)
->
GetMutable
<
std
::
vector
<
Tensor
>>
();
auto
*
target_tensor_array
=
auto
*
target_tensor_array
=
inst_scope_
->
Var
(
var
)
->
GetMutable
<
std
::
vector
<
Tensor
>>
();
inst_scope_
->
Local
Var
(
var
)
->
GetMutable
<
std
::
vector
<
Tensor
>>
();
CHECK
(
!
shared_tensor_array
->
empty
())
CHECK
(
!
shared_tensor_array
->
empty
())
<<
"shared_tensor_array is empty yet"
;
<<
"shared_tensor_array is empty yet"
;
target_tensor_array
->
resize
(
shared_tensor_array
->
size
());
target_tensor_array
->
resize
(
shared_tensor_array
->
size
());
...
@@ -142,12 +151,23 @@ bool TestCase::CheckTensorPrecision(const Tensor* a_tensor,
...
@@ -142,12 +151,23 @@ bool TestCase::CheckTensorPrecision(const Tensor* a_tensor,
b_tensor
->
target
()
==
TARGET
(
kARM
));
b_tensor
->
target
()
==
TARGET
(
kARM
));
const
T
*
a_data
{};
const
T
*
a_data
{};
Tensor
a_host_tensor
;
a_host_tensor
.
Resize
(
a_tensor
->
dims
());
switch
(
a_tensor
->
target
())
{
switch
(
a_tensor
->
target
())
{
case
TARGET
(
kX86
):
case
TARGET
(
kX86
):
case
TARGET
(
kHost
):
case
TARGET
(
kHost
):
case
TARGET
(
kARM
):
case
TARGET
(
kARM
):
a_data
=
static_cast
<
const
T
*>
(
a_tensor
->
raw_data
());
a_data
=
static_cast
<
const
T
*>
(
a_tensor
->
raw_data
());
break
;
break
;
#ifdef LITE_WITH_XPU
case
TARGET
(
kXPU
):
CopySync
<
TARGET
(
kXPU
)
>
(
a_host_tensor
.
mutable_data
<
T
>
(),
a_tensor
->
raw_data
(),
sizeof
(
T
)
*
a_tensor
->
dims
().
production
(),
IoDirection
::
DtoH
);
a_data
=
a_host_tensor
.
data
<
T
>
();
break
;
#endif
default:
default:
// Before compare, need to copy data from `target` device to host.
// Before compare, need to copy data from `target` device to host.
...
...
lite/core/memory.cc
浏览文件 @
69f9cea0
...
@@ -140,6 +140,11 @@ void TargetCopy(TargetType target, void* dst, const void* src, size_t size) {
...
@@ -140,6 +140,11 @@ void TargetCopy(TargetType target, void* dst, const void* src, size_t size) {
dst
,
src
,
size
,
IoDirection
::
HtoD
);
dst
,
src
,
size
,
IoDirection
::
HtoD
);
break
;
break
;
#endif
#endif
#ifdef LITE_WITH_XPU
case
TargetType
::
kXPU
:
TargetWrapperXPU
::
MemcpySync
(
dst
,
src
,
size
,
IoDirection
::
HtoD
);
break
;
#endif
#ifdef LITE_WITH_OPENCL
#ifdef LITE_WITH_OPENCL
case
TargetType
::
kOpenCL
:
case
TargetType
::
kOpenCL
:
TargetWrapperCL
::
MemcpySync
(
dst
,
src
,
size
,
IoDirection
::
DtoD
);
TargetWrapperCL
::
MemcpySync
(
dst
,
src
,
size
,
IoDirection
::
DtoD
);
...
...
lite/core/memory.h
浏览文件 @
69f9cea0
...
@@ -97,6 +97,11 @@ void CopySync(void* dst, const void* src, size_t size, IoDirection dir) {
...
@@ -97,6 +97,11 @@ void CopySync(void* dst, const void* src, size_t size, IoDirection dir) {
case
TARGET
(
kBM
):
case
TARGET
(
kBM
):
TargetWrapper
<
TARGET
(
kBM
)
>::
MemcpySync
(
dst
,
src
,
size
,
dir
);
TargetWrapper
<
TARGET
(
kBM
)
>::
MemcpySync
(
dst
,
src
,
size
,
dir
);
break
;
break
;
#endif
#ifdef LITE_WITH_XPU
case
TARGET
(
kXPU
):
TargetWrapperXPU
::
MemcpySync
(
dst
,
src
,
size
,
dir
);
break
;
#endif
#endif
default:
default:
LOG
(
FATAL
)
LOG
(
FATAL
)
...
...
lite/tests/api/CMakeLists.txt
浏览文件 @
69f9cea0
...
@@ -3,17 +3,19 @@ if(LITE_WITH_XPU)
...
@@ -3,17 +3,19 @@ if(LITE_WITH_XPU)
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
${
ops
}
${
host_kernels
}
${
x86_kernels
}
${
xpu_kernels
}
${
ops
}
${
host_kernels
}
${
x86_kernels
}
${
xpu_kernels
}
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/resnet50
)
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/resnet50
)
add_dependencies
(
test_resnet50_lite_xpu extern_lite_download_resnet50_tar_gz
)
lite_cc_test
(
test_ernie_lite_xpu SRCS test_ernie_lite_xpu.cc
lite_cc_test
(
test_ernie_lite_xpu SRCS test_ernie_lite_xpu.cc
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
${
ops
}
${
host_kernels
}
${
x86_kernels
}
${
xpu_kernels
}
${
ops
}
${
host_kernels
}
${
x86_kernels
}
${
xpu_kernels
}
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/ernie
)
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/ernie
)
add_dependencies
(
test_ernie_lite_xpu extern_lite_download_ernie_tar_gz
)
lite_cc_test
(
test_bert_lite_xpu SRCS test_bert_lite_xpu.cc
lite_cc_test
(
test_bert_lite_xpu SRCS test_bert_lite_xpu.cc
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
${
ops
}
${
host_kernels
}
${
x86_kernels
}
${
xpu_kernels
}
${
ops
}
${
host_kernels
}
${
x86_kernels
}
${
xpu_kernels
}
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/bert
)
ARGS --model_dir=
${
LITE_MODEL_DIR
}
/bert
)
add_dependencies
(
test_bert_lite_xpu extern_lite_download_bert_tar_gz
)
if
(
WITH_TESTING
)
add_dependencies
(
test_resnet50_lite_xpu extern_lite_download_resnet50_tar_gz
)
add_dependencies
(
test_ernie_lite_xpu extern_lite_download_ernie_tar_gz
)
add_dependencies
(
test_bert_lite_xpu extern_lite_download_bert_tar_gz
)
endif
()
endif
()
endif
()
if
(
LITE_WITH_RKNPU
)
if
(
LITE_WITH_RKNPU
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录