Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
69ab2700
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
“ee9972a0d38f5d00f5ca062fc34745e329896654”上不存在“examples/tess/cls0/local/train.py”
未验证
提交
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,
...
@@ -125,6 +125,15 @@ phi::KernelKey FallBackToCpu(const OpKernelType& expected_kernel_key,
return
phi
::
KernelKey
(
phi
::
Backend
::
CPU
,
kernel_key
.
layout
(),
return
phi
::
KernelKey
(
phi
::
Backend
::
CPU
,
kernel_key
.
layout
(),
kernel_key
.
dtype
());
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
#endif
return
phi
::
KernelKey
();
return
phi
::
KernelKey
();
}
}
...
...
paddle/fluid/platform/device/ipu/ipu_strategy.cc
浏览文件 @
69ab2700
...
@@ -120,121 +120,151 @@ IpuStrategy::IpuStrategy() {
...
@@ -120,121 +120,151 @@ IpuStrategy::IpuStrategy() {
RegisterGetter(options_getter, options_type, #name, "string", \
RegisterGetter(options_getter, options_type, #name, "string", \
[&]() { return popart_options.aliased_name; })
[&]() { return popart_options.aliased_name; })
#define ADD_POPART_ENUM_OPTION(name, EnumType) \
ADD_POPART_ENUM_OPTION_ALIAS
(
autodiff_settings
.
stitch_strategy
,
ADD_POPART_ENUM_OPTION_ALIAS(name, name, EnumType)
autodiffSettings
.
stitchStrategy
,
AutodiffStitchStrategy
);
#define ADD_POPART_BOOL_OPTION(name) ADD_POPART_BOOL_OPTION_ALIAS(name, name)
ADD_POPART_ENUM_OPTION_ALIAS
(
batch_serialization_settings
.
transform_context
,
batchSerializationSettings
.
transformContext
,
#define ADD_POPART_UINT64_OPTION(name) \
BatchSerializationTransformContext
);
ADD_POPART_UINT64_OPTION_ALIAS(name, name)
ADD_POPART_ENUM_OPTION_ALIAS
(
batch_serialization_settings
.
method
,
batchSerializationSettings
.
method
,
#define ADD_POPART_DOUBLE_OPTION(name) \
BatchSerializationMethod
);
ADD_POPART_DOUBLE_OPTION_ALIAS(name, name)
ADD_POPART_ENUM_OPTION_ALIAS
(
batch_serialization_settings
.
batch_schedule
,
batchSerializationSettings
.
batchSchedule
,
#define ADD_POPART_STRING_OPTION(name) \
BatchSerializationBatchSchedule
);
ADD_POPART_STRING_OPTION_ALIAS(name, name)
ADD_POPART_ENUM_OPTION_ALIAS
(
auto_recomputation
,
autoRecomputation
,
RecomputationType
);
ADD_POPART_ENUM_OPTION
(
autodiffSettings
.
stitchStrategy
,
ADD_POPART_ENUM_OPTION_ALIAS
(
merge_var_update
,
mergeVarUpdate
,
AutodiffStitchStrategy
);
MergeVarUpdateType
);
ADD_POPART_ENUM_OPTION
(
batchSerializationSettings
.
transformContext
,
ADD_POPART_ENUM_OPTION_ALIAS
(
virtual_graph_mode
,
virtualGraphMode
,
BatchSerializationTransformContext
);
VirtualGraphMode
);
ADD_POPART_ENUM_OPTION
(
batchSerializationSettings
.
method
,
ADD_POPART_ENUM_OPTION_ALIAS
(
synthetic_data_mode
,
syntheticDataMode
,
BatchSerializationMethod
);
SyntheticDataMode
);
ADD_POPART_ENUM_OPTION
(
batchSerializationSettings
.
batchSchedule
,
ADD_POPART_ENUM_OPTION_ALIAS
(
subgraph_copying_strategy
,
BatchSerializationBatchSchedule
);
subgraphCopyingStrategy
,
ADD_POPART_ENUM_OPTION
(
autoRecomputation
,
RecomputationType
);
SubgraphCopyingStrategy
);
ADD_POPART_ENUM_OPTION
(
mergeVarUpdate
,
MergeVarUpdateType
);
ADD_POPART_ENUM_OPTION_ALIAS
(
accumulation_and_replication_reduction_type
,
ADD_POPART_ENUM_OPTION
(
virtualGraphMode
,
VirtualGraphMode
);
accumulationAndReplicationReductionType
,
ADD_POPART_ENUM_OPTION
(
syntheticDataMode
,
SyntheticDataMode
);
ReductionType
);
ADD_POPART_ENUM_OPTION
(
subgraphCopyingStrategy
,
SubgraphCopyingStrategy
);
ADD_POPART_ENUM_OPTION_ALIAS
(
ADD_POPART_ENUM_OPTION
(
accumulationAndReplicationReductionType
,
mean_accumulation_and_replication_reduction_strategy
,
ReductionType
);
meanAccumulationAndReplicationReductionStrategy
,
MeanReductionStrategy
);
ADD_POPART_ENUM_OPTION
(
meanAccumulationAndReplicationReductionStrategy
,
MeanReductionStrategy
);
ADD_POPART_STRING_OPTION_ALIAS
(
log_dir
,
logDir
);
ADD_POPART_STRING_OPTION_ALIAS
(
cache_path
,
cachePath
);
ADD_POPART_STRING_OPTION
(
logDir
);
ADD_POPART_STRING_OPTION_ALIAS
(
partials_type_matmuls
,
partialsTypeMatMuls
);
ADD_POPART_STRING_OPTION
(
cachePath
);
ADD_POPART_STRING_OPTION_ALIAS
(
custom_codelet_compile_flags
,
ADD_POPART_STRING_OPTION
(
partialsTypeMatMuls
);
customCodeletCompileFlags
);
ADD_POPART_STRING_OPTION
(
customCodeletCompileFlags
);
ADD_POPART_STRING_OPTION_ALIAS
(
serialized_poprithms_shift_graphs_dir
,
ADD_POPART_STRING_OPTION
(
serializedPoprithmsShiftGraphsDir
);
serializedPoprithmsShiftGraphsDir
);
ADD_POPART_STRING_OPTION
(
kahnTieBreaker
);
ADD_POPART_STRING_OPTION_ALIAS
(
kahn_tie_breaker
,
kahnTieBreaker
);
ADD_POPART_UINT64_OPTION
(
executionPhaseSettings
.
phases
);
ADD_POPART_UINT64_OPTION_ALIAS
(
execution_phase_settings
.
phases
,
ADD_POPART_UINT64_OPTION
(
executionPhaseSettings
.
stages
);
executionPhaseSettings
.
phases
);
ADD_POPART_UINT64_OPTION
(
batchSerializationSettings
.
factor
);
ADD_POPART_UINT64_OPTION_ALIAS
(
execution_phase_settings
.
stages
,
ADD_POPART_UINT64_OPTION
(
firstDotOp
);
executionPhaseSettings
.
stages
);
ADD_POPART_UINT64_OPTION
(
finalDotOp
);
ADD_POPART_UINT64_OPTION_ALIAS
(
batch_serialization_settings
.
factor
,
ADD_POPART_UINT64_OPTION
(
numIOTiles
);
batchSerializationSettings
.
factor
);
ADD_POPART_UINT64_OPTION
(
mergeVarUpdateMemThreshold
);
ADD_POPART_UINT64_OPTION_ALIAS
(
first_dot_op
,
firstDotOp
);
ADD_POPART_UINT64_OPTION
(
looseThresholdAtPeak
);
ADD_POPART_UINT64_OPTION_ALIAS
(
final_dot_op
,
finalDotOp
);
ADD_POPART_UINT64_OPTION
(
accumulationFactor
);
ADD_POPART_UINT64_OPTION_ALIAS
(
num_io_tiles
,
numIOTiles
);
ADD_POPART_UINT64_OPTION
(
swapLimitScheduler
);
ADD_POPART_UINT64_OPTION_ALIAS
(
merge_var_update_mem_threshold
,
ADD_POPART_UINT64_OPTION
(
globalReplicationFactor
);
mergeVarUpdateMemThreshold
);
ADD_POPART_UINT64_OPTION
(
globalReplicaOffset
);
ADD_POPART_UINT64_OPTION_ALIAS
(
loose_threshold_at_peak
,
looseThresholdAtPeak
);
ADD_POPART_UINT64_OPTION
(
defaultPrefetchBufferingDepth
);
ADD_POPART_UINT64_OPTION_ALIAS
(
accumulation_factor
,
accumulationFactor
);
ADD_POPART_UINT64_OPTION
(
compilationProgressTotal
);
ADD_POPART_UINT64_OPTION_ALIAS
(
swap_limit_scheduler
,
swapLimitScheduler
);
ADD_POPART_UINT64_OPTION
(
transitiveClosureOptimizationThreshold
);
ADD_POPART_UINT64_OPTION_ALIAS
(
global_replication_factor
,
globalReplicationFactor
);
ADD_POPART_BOOL_OPTION
(
batchSerializationSettings
.
concatOnVirtualGraphChange
);
ADD_POPART_UINT64_OPTION_ALIAS
(
global_replica_offset
,
globalReplicaOffset
);
ADD_POPART_BOOL_OPTION
(
ADD_POPART_UINT64_OPTION_ALIAS
(
default_prefetch_buffering_depth
,
defaultPrefetchBufferingDepth
);
ADD_POPART_UINT64_OPTION_ALIAS
(
compilation_progress_total
,
compilationProgressTotal
);
ADD_POPART_UINT64_OPTION_ALIAS
(
transitive_closure_optimization_threshold
,
transitiveClosureOptimizationThreshold
);
ADD_POPART_BOOL_OPTION_ALIAS
(
batch_serialization_settings
.
concat_on_virtual_graph_change
,
batchSerializationSettings
.
concatOnVirtualGraphChange
);
ADD_POPART_BOOL_OPTION_ALIAS
(
batch_serialization_settings
.
concat_on_execution_phase_change
,
batchSerializationSettings
.
concatOnExecutionPhaseChange
);
batchSerializationSettings
.
concatOnExecutionPhaseChange
);
ADD_POPART_BOOL_OPTION
(
ADD_POPART_BOOL_OPTION_ALIAS
(
batch_serialization_settings
.
concat_on_pipeline_stage_change
,
batchSerializationSettings
.
concatOnPipelineStageChange
);
batchSerializationSettings
.
concatOnPipelineStageChange
);
ADD_POPART_BOOL_OPTION
(
strictOpVersions
);
ADD_POPART_BOOL_OPTION_ALIAS
(
strict_op_versions
,
strictOpVersions
);
ADD_POPART_BOOL_OPTION
(
opxAliasChecking
);
ADD_POPART_BOOL_OPTION_ALIAS
(
opx_alias_checking
,
opxAliasChecking
);
ADD_POPART_BOOL_OPTION
(
opxModifyChecking
);
ADD_POPART_BOOL_OPTION_ALIAS
(
opx_modify_checking
,
opxModifyChecking
);
ADD_POPART_BOOL_OPTION
(
dotOpNames
);
ADD_POPART_BOOL_OPTION_ALIAS
(
dot_op_names
,
dotOpNames
);
ADD_POPART_BOOL_OPTION
(
exportPoplarComputationGraph
);
ADD_POPART_BOOL_OPTION_ALIAS
(
export_poplar_computation_graph
,
ADD_POPART_BOOL_OPTION
(
exportPoplarVertexGraph
);
exportPoplarComputationGraph
);
ADD_POPART_BOOL_OPTION
(
separateCallOpPdfs
);
ADD_POPART_BOOL_OPTION_ALIAS
(
export_poplar_vertex_graph
,
ADD_POPART_BOOL_OPTION
(
enableOutlining
);
exportPoplarVertexGraph
);
ADD_POPART_BOOL_OPTION
(
enableOutliningCopyCostPruning
);
ADD_POPART_BOOL_OPTION_ALIAS
(
separate_call_op_pdfs
,
separateCallOpPdfs
);
ADD_POPART_BOOL_OPTION
(
rearrangeAnchorsOnHost
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_outlining
,
enableOutlining
);
ADD_POPART_BOOL_OPTION
(
enablePrefetchDatastreams
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_outlining_copy_cost_pruning
,
ADD_POPART_BOOL_OPTION
(
enableNonStableSoftmax
);
enableOutliningCopyCostPruning
);
ADD_POPART_BOOL_OPTION
(
enableReplicatedGraphs
);
ADD_POPART_BOOL_OPTION_ALIAS
(
rearrange_anchors_on_host
,
ADD_POPART_BOOL_OPTION
(
enableGradientAccumulation
);
rearrangeAnchorsOnHost
);
ADD_POPART_BOOL_OPTION
(
instrumentWithHardwareCycleCounter
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_prefetch_datastreams
,
ADD_POPART_BOOL_OPTION
(
enablePipelining
);
enablePrefetchDatastreams
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_non_stable_softmax
,
enableNonStableSoftmax
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_replicated_graphs
,
enableReplicatedGraphs
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_gradient_accumulation
,
enableGradientAccumulation
);
ADD_POPART_BOOL_OPTION_ALIAS
(
instrument_with_hardware_cycle_counter
,
instrumentWithHardwareCycleCounter
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_pipelining
,
enablePipelining
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_pipelining
,
enablePipelining
);
ADD_POPART_BOOL_OPTION
(
disableGradAccumulationTensorStreams
);
ADD_POPART_BOOL_OPTION_ALIAS
(
disable_grad_accumulation_tensor_streams
,
ADD_POPART_BOOL_OPTION
(
compileEngine
);
disableGradAccumulationTensorStreams
);
ADD_POPART_BOOL_OPTION
(
constantWeights
);
ADD_POPART_BOOL_OPTION_ALIAS
(
compile_engine
,
compileEngine
);
ADD_POPART_BOOL_OPTION
(
enableEngineCaching
);
ADD_POPART_BOOL_OPTION_ALIAS
(
constant_weights
,
constantWeights
);
ADD_POPART_BOOL_OPTION
(
enableMergeExchange
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_engine_caching
,
enableEngineCaching
);
ADD_POPART_BOOL_OPTION
(
enableFloatingPointChecks
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_merge_exchange
,
enableMergeExchange
);
ADD_POPART_BOOL_OPTION
(
enableStochasticRounding
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_floating_point_checks
,
enableFloatingPointChecks
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_stochastic_rounding
,
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_stochastic_rounding
,
enableStochasticRounding
);
enableStochasticRounding
);
ADD_POPART_BOOL_OPTION
(
explicitRecomputation
);
ADD_POPART_BOOL_OPTION_ALIAS
(
explicit_recomputation
,
explicitRecomputation
);
ADD_POPART_BOOL_OPTION
(
enableExplicitMainLoops
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_explicit_main_loops
,
ADD_POPART_BOOL_OPTION
(
useHostCopyOps
);
enableExplicitMainLoops
);
ADD_POPART_BOOL_OPTION
(
aliasZeroCopy
);
ADD_POPART_BOOL_OPTION_ALIAS
(
use_host_copy_ops
,
useHostCopyOps
);
ADD_POPART_BOOL_OPTION
(
delayVarUpdates
);
ADD_POPART_BOOL_OPTION_ALIAS
(
alias_zero_copy
,
aliasZeroCopy
);
ADD_POPART_BOOL_OPTION
(
enableFullyConnectedPass
);
ADD_POPART_BOOL_OPTION_ALIAS
(
delay_var_updates
,
delayVarUpdates
);
ADD_POPART_BOOL_OPTION
(
enableSerializedMatmuls
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_fully_connected_pass
,
ADD_POPART_BOOL_OPTION
(
enableStableNorm
);
enableFullyConnectedPass
);
ADD_POPART_BOOL_OPTION
(
decomposeGradSum
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_serialized_matmuls
,
ADD_POPART_BOOL_OPTION
(
enableDistributedReplicatedGraphs
);
enableSerializedMatmuls
);
ADD_POPART_BOOL_OPTION
(
groupHostSync
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_stable_norm
,
enableStableNorm
);
ADD_POPART_BOOL_OPTION
(
automaticLossScalingSettings
.
enabled
);
ADD_POPART_BOOL_OPTION_ALIAS
(
decompose_grad_sum
,
decomposeGradSum
);
ADD_POPART_BOOL_OPTION
(
instrumentWithHardwareCycleCounter
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_distributed_replicated_graphs
,
ADD_POPART_BOOL_OPTION
(
enableSupportedDataTypeCasting
);
enableDistributedReplicatedGraphs
);
ADD_POPART_BOOL_OPTION
(
groupNormStridedChannelGrouping
);
ADD_POPART_BOOL_OPTION_ALIAS
(
group_host_sync
,
groupHostSync
);
ADD_POPART_BOOL_OPTION
(
scheduleNonWeightUpdateGradientConsumersEarly
);
ADD_POPART_BOOL_OPTION_ALIAS
(
automatic_loss_scaling_settings
.
enabled
,
automaticLossScalingSettings
.
enabled
);
ADD_POPART_DOUBLE_OPTION
(
outlineSequenceBreakCost
);
ADD_POPART_BOOL_OPTION_ALIAS
(
instrument_with_hardware_cycle_counter
,
ADD_POPART_DOUBLE_OPTION
(
outlineThreshold
);
instrumentWithHardwareCycleCounter
);
ADD_POPART_DOUBLE_OPTION
(
timeLimitScheduler
);
ADD_POPART_BOOL_OPTION_ALIAS
(
enable_supported_data_type_casting
,
ADD_POPART_DOUBLE_OPTION
(
automaticLossScalingSettings
.
binEdgeLocation
);
enableSupportedDataTypeCasting
);
ADD_POPART_DOUBLE_OPTION
(
ADD_POPART_BOOL_OPTION_ALIAS
(
group_norm_strided_channel_grouping
,
groupNormStridedChannelGrouping
);
ADD_POPART_BOOL_OPTION_ALIAS
(
schedule_non_weight_update_gradient_consumers_early
,
scheduleNonWeightUpdateGradientConsumersEarly
);
ADD_POPART_DOUBLE_OPTION_ALIAS
(
outline_sequence_break_cost
,
outlineSequenceBreakCost
);
ADD_POPART_DOUBLE_OPTION_ALIAS
(
outline_threshold
,
outlineThreshold
);
ADD_POPART_DOUBLE_OPTION_ALIAS
(
time_limit_scheduler
,
timeLimitScheduler
);
ADD_POPART_DOUBLE_OPTION_ALIAS
(
automatic_loss_scaling_settings
.
bin_edge_location
,
automaticLossScalingSettings
.
binEdgeLocation
);
ADD_POPART_DOUBLE_OPTION_ALIAS
(
automatic_loss_scaling_settings
.
threshold_upper_count_proportion
,
automaticLossScalingSettings
.
thresholdUpperCountProportion
);
automaticLossScalingSettings
.
thresholdUpperCountProportion
);
#undef ADD_POPART_STRING_OPTION
#undef ADD_POPART_DOUBLE_OPTION
#undef ADD_POPART_UINT64_OPTION
#undef ADD_POPART_BOOL_OPTION
#undef ADD_POPART_ENUM_OPTION
#undef ADD_POPART_STRING_OPTION_ALIAS
#undef ADD_POPART_STRING_OPTION_ALIAS
#undef ADD_POPART_DOUBLE_OPTION_ALIAS
#undef ADD_POPART_DOUBLE_OPTION_ALIAS
#undef ADD_POPART_UINT64_OPTION_ALIAS
#undef ADD_POPART_UINT64_OPTION_ALIAS
...
@@ -278,14 +308,14 @@ IpuStrategy::IpuStrategy() {
...
@@ -278,14 +308,14 @@ IpuStrategy::IpuStrategy() {
});
});
RegisterSetter
(
RegisterSetter
(
container_options
,
"dot
C
hecks"
,
container_options
,
"dot
_c
hecks"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
std
::
uint64_t
value
=
std
::
stoul
(
p
.
first
);
std
::
uint64_t
value
=
std
::
stoul
(
p
.
first
);
popart_options
.
dotChecks
.
insert
(
static_cast
<
popart
::
DotCheck
>
(
value
));
popart_options
.
dotChecks
.
insert
(
static_cast
<
popart
::
DotCheck
>
(
value
));
});
});
RegisterGetter
(
RegisterGetter
(
vector_options_getter
,
options_type
,
"dot
C
hecks"
,
"vector"
,
[
&
]()
{
vector_options_getter
,
options_type
,
"dot
_c
hecks"
,
"vector"
,
[
&
]()
{
std
::
vector
<
std
::
string
>
res
;
std
::
vector
<
std
::
string
>
res
;
for
(
auto
x
:
popart_options
.
dotChecks
)
{
for
(
auto
x
:
popart_options
.
dotChecks
)
{
res
.
push_back
(
std
::
to_string
(
static_cast
<
std
::
uint64_t
>
(
x
)));
res
.
push_back
(
std
::
to_string
(
static_cast
<
std
::
uint64_t
>
(
x
)));
...
@@ -293,7 +323,7 @@ IpuStrategy::IpuStrategy() {
...
@@ -293,7 +323,7 @@ IpuStrategy::IpuStrategy() {
return
res
;
return
res
;
});
});
RegisterSetter
(
container_options
,
"hardware
I
nstrumentations"
,
RegisterSetter
(
container_options
,
"hardware
_i
nstrumentations"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
std
::
uint64_t
value
=
std
::
stoul
(
p
.
first
);
std
::
uint64_t
value
=
std
::
stoul
(
p
.
first
);
popart_options
.
hardwareInstrumentations
.
insert
(
popart_options
.
hardwareInstrumentations
.
insert
(
...
@@ -301,8 +331,8 @@ IpuStrategy::IpuStrategy() {
...
@@ -301,8 +331,8 @@ IpuStrategy::IpuStrategy() {
});
});
RegisterGetter
(
RegisterGetter
(
vector_options_getter
,
options_type
,
"hardware
Instrumentations"
,
"vector
"
,
vector_options_getter
,
options_type
,
"hardware
_instrumentations
"
,
[
&
]()
{
"vector"
,
[
&
]()
{
std
::
vector
<
std
::
string
>
res
;
std
::
vector
<
std
::
string
>
res
;
for
(
auto
x
:
popart_options
.
hardwareInstrumentations
)
{
for
(
auto
x
:
popart_options
.
hardwareInstrumentations
)
{
res
.
push_back
(
std
::
to_string
(
static_cast
<
std
::
uint64_t
>
(
x
)));
res
.
push_back
(
std
::
to_string
(
static_cast
<
std
::
uint64_t
>
(
x
)));
...
@@ -310,12 +340,12 @@ IpuStrategy::IpuStrategy() {
...
@@ -310,12 +340,12 @@ IpuStrategy::IpuStrategy() {
return
res
;
return
res
;
});
});
RegisterSetter
(
container_options
,
"custom
C
odelets"
,
RegisterSetter
(
container_options
,
"custom
_c
odelets"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
popart_options
.
customCodelets
.
push_back
(
p
.
first
);
popart_options
.
customCodelets
.
push_back
(
p
.
first
);
});
});
RegisterGetter
(
vector_options_getter
,
options_type
,
"custom
C
odelets"
,
RegisterGetter
(
vector_options_getter
,
options_type
,
"custom
_c
odelets"
,
"vector"
,
[
&
]()
{
"vector"
,
[
&
]()
{
std
::
vector
<
std
::
string
>
res
;
std
::
vector
<
std
::
string
>
res
;
for
(
auto
x
:
popart_options
.
customCodelets
)
{
for
(
auto
x
:
popart_options
.
customCodelets
)
{
...
@@ -324,44 +354,44 @@ IpuStrategy::IpuStrategy() {
...
@@ -324,44 +354,44 @@ IpuStrategy::IpuStrategy() {
return
res
;
return
res
;
});
});
RegisterSetter
(
container_options
,
"engine
O
ptions"
,
RegisterSetter
(
container_options
,
"engine
_o
ptions"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
popart_options
.
engineOptions
.
emplace
(
p
);
popart_options
.
engineOptions
.
emplace
(
p
);
});
});
RegisterGetter
(
map_options_getter
,
options_type
,
"engine
O
ptions"
,
"map"
,
RegisterGetter
(
map_options_getter
,
options_type
,
"engine
_o
ptions"
,
"map"
,
[
&
]()
{
return
popart_options
.
engineOptions
;
});
[
&
]()
{
return
popart_options
.
engineOptions
;
});
RegisterSetter
(
container_options
,
"report
O
ptions"
,
RegisterSetter
(
container_options
,
"report
_o
ptions"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
popart_options
.
reportOptions
.
emplace
(
p
);
popart_options
.
reportOptions
.
emplace
(
p
);
});
});
RegisterGetter
(
map_options_getter
,
options_type
,
"report
O
ptions"
,
"map"
,
RegisterGetter
(
map_options_getter
,
options_type
,
"report
_o
ptions"
,
"map"
,
[
&
]()
{
return
popart_options
.
reportOptions
;
});
[
&
]()
{
return
popart_options
.
reportOptions
;
});
RegisterSetter
(
container_options
,
"convolution
O
ptions"
,
RegisterSetter
(
container_options
,
"convolution
_o
ptions"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
popart_options
.
convolutionOptions
.
emplace
(
p
);
popart_options
.
convolutionOptions
.
emplace
(
p
);
});
});
RegisterGetter
(
map_options_getter
,
options_type
,
"convolution
O
ptions"
,
"map"
,
RegisterGetter
(
map_options_getter
,
options_type
,
"convolution
_o
ptions"
,
"map"
,
[
&
]()
{
return
popart_options
.
convolutionOptions
;
});
[
&
]()
{
return
popart_options
.
convolutionOptions
;
});
RegisterSetter
(
container_options
,
"lstm
O
ptions"
,
RegisterSetter
(
container_options
,
"lstm
_o
ptions"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
popart_options
.
lstmOptions
.
emplace
(
p
);
popart_options
.
lstmOptions
.
emplace
(
p
);
});
});
RegisterGetter
(
map_options_getter
,
options_type
,
"lstm
O
ptions"
,
"map"
,
RegisterGetter
(
map_options_getter
,
options_type
,
"lstm
_o
ptions"
,
"map"
,
[
&
]()
{
return
popart_options
.
lstmOptions
;
});
[
&
]()
{
return
popart_options
.
lstmOptions
;
});
RegisterSetter
(
container_options
,
"gcl
O
ptions"
,
RegisterSetter
(
container_options
,
"gcl
_o
ptions"
,
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
[
&
](
const
std
::
pair
<
std
::
string
,
std
::
string
>&
p
)
{
popart_options
.
gclOptions
.
emplace
(
p
);
popart_options
.
gclOptions
.
emplace
(
p
);
});
});
RegisterGetter
(
map_options_getter
,
options_type
,
"gcl
O
ptions"
,
"map"
,
RegisterGetter
(
map_options_getter
,
options_type
,
"gcl
_o
ptions"
,
"map"
,
[
&
]()
{
return
popart_options
.
gclOptions
;
});
[
&
]()
{
return
popart_options
.
gclOptions
;
});
}
}
...
@@ -415,21 +445,21 @@ void IpuStrategy::SetTensorLocation(const std::string& tensor,
...
@@ -415,21 +445,21 @@ void IpuStrategy::SetTensorLocation(const std::string& tensor,
"Unknown tensor location: %s"
,
tensor
));
"Unknown tensor location: %s"
,
tensor
));
}
}
if
(
opt
==
"min
ElementsForOffC
hip"
)
{
if
(
opt
==
"min
_elements_for_off_c
hip"
)
{
settings
->
minElementsForOffChip
=
value
;
settings
->
minElementsForOffChip
=
value
;
}
else
if
(
opt
==
"min
ElementsForReplicatedTensorS
harding"
)
{
}
else
if
(
opt
==
"min
_elements_for_replicated_tensor_s
harding"
)
{
settings
->
minElementsForReplicatedTensorSharding
=
value
;
settings
->
minElementsForReplicatedTensorSharding
=
value
;
}
else
if
(
opt
==
"on
C
hip"
)
{
}
else
if
(
opt
==
"on
_c
hip"
)
{
settings
->
location
.
storage
=
value
>
0
?
popart
::
TensorStorage
::
OnChip
settings
->
location
.
storage
=
value
>
0
?
popart
::
TensorStorage
::
OnChip
:
popart
::
TensorStorage
::
OffChip
;
:
popart
::
TensorStorage
::
OffChip
;
}
else
if
(
opt
==
"use
ReplicatedTensorS
harding"
)
{
}
else
if
(
opt
==
"use
_replicated_tensor_s
harding"
)
{
settings
->
location
.
replicatedTensorSharding
=
settings
->
location
.
replicatedTensorSharding
=
value
>
0
?
popart
::
ReplicatedTensorSharding
::
On
value
>
0
?
popart
::
ReplicatedTensorSharding
::
On
:
popart
::
ReplicatedTensorSharding
::
Off
;
:
popart
::
ReplicatedTensorSharding
::
Off
;
}
else
if
(
opt
==
"use
IOTilesToL
oad"
)
{
}
else
if
(
opt
==
"use
_io_tiles_to_l
oad"
)
{
settings
->
location
.
loadTileSet
=
settings
->
location
.
loadTileSet
=
value
>
0
?
popart
::
TileSet
::
IO
:
popart
::
TileSet
::
Compute
;
value
>
0
?
popart
::
TileSet
::
IO
:
popart
::
TileSet
::
Compute
;
}
else
if
(
opt
==
"use
IOTilesToS
tore"
)
{
}
else
if
(
opt
==
"use
_io_tiles_to_s
tore"
)
{
settings
->
location
.
storageTileSet
=
settings
->
location
.
storageTileSet
=
value
>
0
?
popart
::
TileSet
::
IO
:
popart
::
TileSet
::
Compute
;
value
>
0
?
popart
::
TileSet
::
IO
:
popart
::
TileSet
::
Compute
;
}
else
{
}
else
{
...
@@ -464,6 +494,20 @@ std::string IpuStrategy::GetOptionType(const std::string& option) {
...
@@ -464,6 +494,20 @@ std::string IpuStrategy::GetOptionType(const std::string& option) {
return
options_type
[
option
];
return
options_type
[
option
];
}
}
std
::
vector
<
std
::
string
>
IpuStrategy
::
GetAllOptionNames
()
{
std
::
vector
<
std
::
string
>
names
;
for
(
auto
&
option
:
options_getter
)
{
names
.
push_back
(
option
.
first
);
}
for
(
auto
&
option
:
vector_options_getter
)
{
names
.
push_back
(
option
.
first
);
}
for
(
auto
&
option
:
map_options_getter
)
{
names
.
push_back
(
option
.
first
);
}
return
names
;
}
void
IpuStrategy
::
EnablePattern
(
const
std
::
string
&
t
)
{
void
IpuStrategy
::
EnablePattern
(
const
std
::
string
&
t
)
{
VLOG
(
10
)
<<
"enable popart pattern: "
<<
t
;
VLOG
(
10
)
<<
"enable popart pattern: "
<<
t
;
popart_patterns
.
enablePattern
(
t
,
true
);
popart_patterns
.
enablePattern
(
t
,
true
);
...
...
paddle/fluid/platform/device/ipu/ipu_strategy.h
浏览文件 @
69ab2700
...
@@ -24,7 +24,8 @@ namespace paddle {
...
@@ -24,7 +24,8 @@ namespace paddle {
namespace
platform
{
namespace
platform
{
namespace
ipu
{
namespace
ipu
{
struct
IpuStrategy
{
class
IpuStrategy
{
public:
IpuStrategy
();
IpuStrategy
();
// TODO(alleng) create PaddleOptions
// TODO(alleng) create PaddleOptions
...
@@ -75,22 +76,30 @@ struct IpuStrategy {
...
@@ -75,22 +76,30 @@ struct IpuStrategy {
// custom ops
// custom ops
std
::
vector
<
IpuCustomOpIdentifier
>
custom_ops
;
std
::
vector
<
IpuCustomOpIdentifier
>
custom_ops
;
private:
public:
std
::
map
<
std
::
string
,
std
::
function
<
void
(
bool
)
>>
bool_options
;
void
AddBoolOption
(
const
std
::
string
&
option
,
bool
value
);
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
uint64_t
)
>>
uint64_options
;
void
AddUint64Option
(
const
std
::
string
&
option
,
std
::
uint64_t
value
);
std
::
map
<
std
::
string
,
std
::
function
<
void
(
double
)
>>
double_options
;
void
AddDoubleOption
(
const
std
::
string
&
option
,
double
value
);
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
string
)
>>
string_options
;
void
AddStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
std
::
map
<
std
::
string
,
void
InsertStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
std
::
function
<
void
(
std
::
pair
<
std
::
string
,
std
::
string
>
)
>>
void
InsertStringPairOption
(
const
std
::
string
&
option
,
const
std
::
string
&
key
,
container_options
;
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
::
string
GetOption
(
const
std
::
string
&
);
std
::
map
<
std
::
string
,
std
::
function
<
std
::
vector
<
std
::
string
>
()
>>
std
::
vector
<
std
::
string
>
GetVectorOption
(
const
std
::
string
&
);
vector_options_getter
;
std
::
map
<
std
::
string
,
std
::
string
>
GetMapOption
(
const
std
::
string
&
);
std
::
map
<
std
::
string
,
std
::
function
<
std
::
map
<
std
::
string
,
std
::
string
>
()
>>
std
::
string
GetOptionType
(
const
std
::
string
&
);
map_options_getter
;
std
::
vector
<
std
::
string
>
GetAllOptionNames
();
std
::
map
<
std
::
string
,
std
::
string
>
options_type
;
void
EnablePattern
(
const
std
::
string
&
t
);
void
DisablePattern
(
const
std
::
string
&
t
);
const
bool
IsPatternEnabled
(
const
std
::
string
&
t
);
private:
template
<
typename
ValueType
>
template
<
typename
ValueType
>
void
set
(
void
set
(
const
std
::
string
&
key
,
ValueType
value
,
const
std
::
string
&
key
,
ValueType
value
,
...
@@ -117,27 +126,20 @@ struct IpuStrategy {
...
@@ -117,27 +126,20 @@ struct IpuStrategy {
return
it
->
second
();
return
it
->
second
();
}
}
public:
std
::
map
<
std
::
string
,
std
::
function
<
void
(
bool
)
>>
bool_options
;
void
AddBoolOption
(
const
std
::
string
&
option
,
bool
value
);
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
uint64_t
)
>>
uint64_options
;
void
AddUint64Option
(
const
std
::
string
&
option
,
std
::
uint64_t
value
);
std
::
map
<
std
::
string
,
std
::
function
<
void
(
double
)
>>
double_options
;
void
AddDoubleOption
(
const
std
::
string
&
option
,
double
value
);
std
::
map
<
std
::
string
,
std
::
function
<
void
(
std
::
string
)
>>
string_options
;
void
AddStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
std
::
map
<
std
::
string
,
void
InsertStringOption
(
const
std
::
string
&
option
,
const
std
::
string
&
value
);
std
::
function
<
void
(
std
::
pair
<
std
::
string
,
std
::
string
>
)
>>
void
InsertStringPairOption
(
const
std
::
string
&
option
,
const
std
::
string
&
key
,
container_options
;
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
&
);
void
EnablePattern
(
const
std
::
string
&
t
);
std
::
map
<
std
::
string
,
std
::
function
<
std
::
string
()
>>
options_getter
;
void
DisablePattern
(
const
std
::
string
&
t
);
std
::
map
<
std
::
string
,
std
::
function
<
std
::
vector
<
std
::
string
>
()
>>
const
bool
IsPatternEnabled
(
const
std
::
string
&
t
);
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
}
// namespace ipu
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
69ab2700
...
@@ -3919,6 +3919,8 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -3919,6 +3919,8 @@ All parameter, weight, gradient are variables in Paddle.
}
}
return
res
;
return
res
;
})
})
.
def
(
"get_all_option_names"
,
&
platform
::
ipu
::
IpuStrategy
::
GetAllOptionNames
)
.
def
(
"enable_pattern"
,
&
platform
::
ipu
::
IpuStrategy
::
EnablePattern
)
.
def
(
"enable_pattern"
,
&
platform
::
ipu
::
IpuStrategy
::
EnablePattern
)
.
def
(
"disable_pattern"
,
&
platform
::
ipu
::
IpuStrategy
::
DisablePattern
)
.
def
(
"disable_pattern"
,
&
platform
::
ipu
::
IpuStrategy
::
DisablePattern
)
.
def
(
"is_pattern_enabled"
,
&
platform
::
ipu
::
IpuStrategy
::
IsPatternEnabled
);
.
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录