Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
8c0397c6
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看板
未验证
提交
8c0397c6
编写于
1月 02, 2020
作者:
H
hong19860320
提交者:
GitHub
1月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[LITE][XPU] Supporting llvm and xpu device target (#2711)
上级
ab30ccc2
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
30 addition
and
8 deletion
+30
-8
lite/backends/xpu/device.cc
lite/backends/xpu/device.cc
+5
-2
lite/backends/xpu/device.h
lite/backends/xpu/device.h
+18
-4
lite/kernels/xpu/bridges/utility.cc
lite/kernels/xpu/bridges/utility.cc
+1
-1
lite/kernels/xpu/subgraph_compute.cc
lite/kernels/xpu/subgraph_compute.cc
+1
-1
lite/tools/build_xpu.sh
lite/tools/build_xpu.sh
+5
-0
未找到文件。
lite/backends/xpu/device.cc
浏览文件 @
8c0397c6
...
...
@@ -36,8 +36,11 @@ std::unique_ptr<xtcl::network::xRuntimeInstance> Device::Build(
}
xtcl
::
xNetwork
network
=
builder
->
FinalizeNetwork
(
xtcl
::
relay
::
TupleNode
::
make
(
all_outs
));
auto
target
=
xtcl
::
Target
::
Create
(
device_name_
);
auto
compiler
=
xtcl
::
network
::
xTensorCompiler
(
network
,
target
);
auto
target
=
xtcl
::
NullValue
<
xtcl
::
Target
>
();
if
(
!
target_
.
empty
())
{
target
=
xtcl
::
Target
::
Create
(
target_
);
}
xtcl
::
network
::
xTensorCompiler
compiler
(
network
,
target
);
compiler
.
SetParams
(
*
params
);
// Set the data of constant tensors
compiler
.
Build
();
VLOG
(
3
)
<<
"[XPU] Build done"
;
...
...
lite/backends/xpu/device.h
浏览文件 @
8c0397c6
...
...
@@ -15,6 +15,7 @@
#pragma once
#include <xtcl/xtcl.h>
#include <cstdlib>
#include <memory>
#include <string>
#include <utility>
...
...
@@ -30,7 +31,18 @@ class Device {
static
Device
x
;
return
x
;
}
Device
()
{}
Device
()
{
char
*
name
=
std
::
getenv
(
"XPU_DEVICE_NAME"
);
if
(
name
)
{
name_
=
std
::
string
(
name
);
}
// XPU_DEVICE_TARGET for XPU model building, which supports 'llvm' and 'xpu
// -libs=xdnn'
char
*
target
=
std
::
getenv
(
"XPU_DEVICE_TARGET"
);
if
(
target
)
{
target_
=
std
::
string
(
target
);
}
}
// Build the XPU graph to the XPU runtime, return the XPU runtime which can be
// used to run inference.
...
...
@@ -39,10 +51,12 @@ class Device {
xtcl
::
network
::
xTensorCompiler
::
ParamNDArrayMap
*
params
,
std
::
vector
<
xtcl
::
xExpr
*>*
outputs
);
const
std
::
string
name
()
const
{
return
name_
;
}
const
std
::
string
target
()
const
{
return
target_
;
}
private:
// Keep reserved fields
int
device_id_
{
0
};
std
::
string
device_name_
{
"llvm"
};
std
::
string
name_
{
""
};
std
::
string
target_
{
""
};
};
}
// namespace xpu
...
...
lite/kernels/xpu/bridges/utility.cc
浏览文件 @
8c0397c6
...
...
@@ -103,7 +103,7 @@ DLDeviceType CvtDLDeviceType(TargetType in_type) {
out_type
=
kDLGPU
;
break
;
case
TARGET
(
kXPU
):
out_type
=
kDLCPU
;
out_type
=
static_cast
<
DLDeviceType
>
(
kDLXPU
)
;
break
;
default:
LOG
(
FATAL
)
<<
"[XPU] Can not convert target type("
<<
TargetToStr
(
in_type
)
...
...
lite/kernels/xpu/subgraph_compute.cc
浏览文件 @
8c0397c6
...
...
@@ -175,7 +175,7 @@ int SubgraphEngine::LaunchDeviceProgram() {
// Update the data pointer of DLTensor to track the origin input tensors
device_itensors_
[
i
].
data
=
const_cast
<
void
*>
(
origin_itensors_
[
i
]
->
raw_data
());
device_program_
->
SetInput
ZeroCopy
(
device_inames_
[
i
],
&
device_itensors_
[
i
]);
device_program_
->
SetInput
(
device_inames_
[
i
],
&
device_itensors_
[
i
]);
}
// Run the XPU model
auto
GetCurrentUS
=
[]()
->
double
{
...
...
lite/tools/build_xpu.sh
浏览文件 @
8c0397c6
...
...
@@ -104,6 +104,11 @@ function main {
build_xpu
shift
;;
full_publish
)
TARGET_NAME
=
publish_inference
build_xpu
shift
;;
*
)
# unknown option
print_usage
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录