Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
69ab2700
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2310
Star
20933
Fork
5423
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
69ab2700
编写于
3月 01, 2022
作者:
A
Allen Guo
提交者:
GitHub
3月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compiling and running with ipu (#39920)
上级
09039636
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
231 addition
and
166 deletion
+231
-166
paddle/fluid/framework/phi_utils.cc
paddle/fluid/framework/phi_utils.cc
+9
-0
paddle/fluid/platform/device/ipu/ipu_strategy.cc
paddle/fluid/platform/device/ipu/ipu_strategy.cc
+175
-131
paddle/fluid/platform/device/ipu/ipu_strategy.h
paddle/fluid/platform/device/ipu/ipu_strategy.h
+37
-35
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+2
-0
python/paddle/fluid/tests/unittests/ipu/CMakeLists.txt
python/paddle/fluid/tests/unittests/ipu/CMakeLists.txt
+8
-0
未找到文件。
paddle/fluid/framework/phi_utils.cc
浏览文件 @
69ab2700
...
...
@@ -125,6 +125,15 @@ phi::KernelKey FallBackToCpu(const OpKernelType& expected_kernel_key,
return
phi
::
KernelKey
(
phi
::
Backend
::
CPU
,
kernel_key
.
layout
(),
kernel_key
.
dtype
());
}
#endif
#ifdef PADDLE_WITH_IPU
if
(
platform
::
is_ipu_place
(
expected_kernel_key
.
place_
))
{
VLOG
(
3
)
<<
"pten missing IPU kernel: "
<<
op
.
Type
()
<<
", expected_kernel_key:"
<<
expected_kernel_key
<<
", fallbacking to CPU one!"
;
return
phi
::
KernelKey
(
phi
::
Backend
::
CPU
,
kernel_key
.
layout
(),
kernel_key
.
dtype
());
}
#endif
return
phi
::
KernelKey
();
}
...
...
paddle/fluid/platform/device/ipu/ipu_strategy.cc
浏览文件 @
69ab2700
此差异已折叠。
点击以展开。
paddle/fluid/platform/device/ipu/ipu_strategy.h
浏览文件 @
69ab2700
...
...
@@ -24,7 +24,8 @@ namespace paddle {
namespace
platform
{
namespace
ipu
{
struct
IpuStrategy
{
class
IpuStrategy
{
public:
IpuStrategy
();
// TODO(alleng) create PaddleOptions
...
...
@@ -75,22 +76,30 @@ struct IpuStrategy {
// custom ops
std
::
vector
<
IpuCustomOpIdentifier
>
custom_ops
;
private:
std
::
map
<
std
::
string
,
std
::
function
<
void
(
bool
)
>>
bool_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
uint64_t
)
>>
uint64_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
double
)
>>
double_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
string
)
>>
string_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
pair
<
std
::
string
,
std
::
string
>
)
>>
container_options
;
public:
void
AddBoolOption
(
const
std
::
string
&
option
,
bool
value
);
void
AddUint64Option
(
const
std
::
string
&
option
,
std
::
uint64_t
value
);
void
AddDoubleOption
(
const
std
::
string
&
option
,
double
value
);
void
AddStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
void
InsertStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
void
InsertStringPairOption
(
const
std
::
string
&
option
,
const
std
::
string
&
key
,
const
std
::
string
&
value
);
void
SetTensorLocation
(
const
std
::
string
&
tensor
,
const
std
::
string
&
option
,
std
::
uint64_t
value
);
void
AddCustomOp
(
const
std
::
string
&
paddle_op
,
const
std
::
string
&
popart_op
,
const
std
::
string
&
domain
,
int
version
);
std
::
map
<
std
::
string
,
std
::
function
<
std
::
string
()
>>
options_getter
;
std
::
map
<
std
::
string
,
std
::
function
<
std
::
vector
<
std
::
string
>
()
>>
vector_options_getter
;
std
::
map
<
std
::
string
,
std
::
function
<
std
::
map
<
std
::
string
,
std
::
string
>
()
>>
map_options_getter
;
std
::
map
<
std
::
string
,
std
::
string
>
options_type
;
std
::
string
GetOption
(
const
std
::
string
&
);
std
::
vector
<
std
::
string
>
GetVectorOption
(
const
std
::
string
&
);
std
::
map
<
std
::
string
,
std
::
string
>
GetMapOption
(
const
std
::
string
&
);
std
::
string
GetOptionType
(
const
std
::
string
&
);
std
::
vector
<
std
::
string
>
GetAllOptionNames
();
void
EnablePattern
(
const
std
::
string
&
t
);
void
DisablePattern
(
const
std
::
string
&
t
);
const
bool
IsPatternEnabled
(
const
std
::
string
&
t
);
private:
template
<
typename
ValueType
>
void
set
(
const
std
::
string
&
key
,
ValueType
value
,
...
...
@@ -117,27 +126,20 @@ struct IpuStrategy {
return
it
->
second
();
}
public:
void
AddBoolOption
(
const
std
::
string
&
option
,
bool
value
);
void
AddUint64Option
(
const
std
::
string
&
option
,
std
::
uint64_t
value
);
void
AddDoubleOption
(
const
std
::
string
&
option
,
double
value
);
void
AddStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
void
InsertStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
void
InsertStringPairOption
(
const
std
::
string
&
option
,
const
std
::
string
&
key
,
const
std
::
string
&
value
);
void
SetTensorLocation
(
const
std
::
string
&
tensor
,
const
std
::
string
&
option
,
std
::
uint64_t
value
);
void
AddCustomOp
(
const
std
::
string
&
paddle_op
,
const
std
::
string
&
popart_op
,
const
std
::
string
&
domain
,
int
version
);
std
::
string
GetOption
(
const
std
::
string
&
);
std
::
vector
<
std
::
string
>
GetVectorOption
(
const
std
::
string
&
);
std
::
map
<
std
::
string
,
std
::
string
>
GetMapOption
(
const
std
::
string
&
);
std
::
string
GetOptionType
(
const
std
::
string
&
);
std
::
map
<
std
::
string
,
std
::
function
<
void
(
bool
)
>>
bool_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
uint64_t
)
>>
uint64_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
double
)
>>
double_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
string
)
>>
string_options
;
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
pair
<
std
::
string
,
std
::
string
>
)
>>
container_options
;
void
EnablePattern
(
const
std
::
string
&
t
);
void
DisablePattern
(
const
std
::
string
&
t
);
const
bool
IsPatternEnabled
(
const
std
::
string
&
t
);
std
::
map
<
std
::
string
,
std
::
function
<
std
::
string
()
>>
options_getter
;
std
::
map
<
std
::
string
,
std
::
function
<
std
::
vector
<
std
::
string
>
()
>>
vector_options_getter
;
std
::
map
<
std
::
string
,
std
::
function
<
std
::
map
<
std
::
string
,
std
::
string
>
()
>>
map_options_getter
;
std
::
map
<
std
::
string
,
std
::
string
>
options_type
;
};
}
// namespace ipu
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
69ab2700
...
...
@@ -3919,6 +3919,8 @@ All parameter, weight, gradient are variables in Paddle.
}
return
res
;
})
.
def
(
"get_all_option_names"
,
&
platform
::
ipu
::
IpuStrategy
::
GetAllOptionNames
)
.
def
(
"enable_pattern"
,
&
platform
::
ipu
::
IpuStrategy
::
EnablePattern
)
.
def
(
"disable_pattern"
,
&
platform
::
ipu
::
IpuStrategy
::
DisablePattern
)
.
def
(
"is_pattern_enabled"
,
&
platform
::
ipu
::
IpuStrategy
::
IsPatternEnabled
);
...
...
python/paddle/fluid/tests/unittests/ipu/CMakeLists.txt
0 → 100644
浏览文件 @
69ab2700
if
(
WITH_IPU
)
file
(
GLOB TEST_OPS RELATIVE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"test_*.py"
)
string
(
REPLACE
".py"
""
TEST_OPS
"
${
TEST_OPS
}
"
)
foreach
(
TEST_OP
${
TEST_OPS
}
)
py_test_modules
(
${
TEST_OP
}
MODULES
${
TEST_OP
}
)
endforeach
(
TEST_OP
)
endif
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录