IpuCompiledProgram¶
- class paddle.static. IpuCompiledProgram ( program=None, scope=None, ipu_strategy=None ) [source]
-
The IpuCompiledProgram is used to transform a program to a ipu-target program, such as forward graph extraction, computing graph transformation, useless scale Ops clean, etc.
- Parameters
-
program (Program, optional) – This parameter represents the
Program
to be executed. Default is None, which means the program will be set to the default programpaddle.static.default_main_program()
.scope (Scope, optional) – The scope used to run this program, you can switch it to different scope. Default is None, which means use the global scope
paddle.static.global_scope()
.ipu_strategy (IpuStrategy, optional) – This argument is used to build the program with the specified options, such as half computation, training or inference session, the number of IPUs, etc. Default is None, which means build the program based on the default ipu_strategy.
- Returns
-
IpuCompiledProgram
Example
>>> >>> import paddle >>> import paddle.static as static >>> paddle.enable_static() >>> a = static.data(name='data', shape=[None, 1], dtype='int32') >>> b = a + 1 >>> main_prog = static.default_main_program() >>> ipu_strategy = static.IpuStrategy() >>> ipu_strategy.set_graph_config(num_ipus=1, is_training=True, micro_batch_size=1) >>> ipu_strategy.set_pipelining_config(enable_pipelining=False, batches_per_step=1, enable_gradient_accumulation=False, accumulation_factor=1) >>> ipu_strategy.set_precision_config(enable_fp16=False) >>> ipu_compiled_program = static.IpuCompiledProgram( ... main_prog, ... ipu_strategy=ipu_strategy)
-
compile
(
feed_list,
fetch_list
)
compile¶
-
This interface is used to compile the input Program to a program to run the model on the ipu.
- Parameters
-
feed_list (list) – This parameter represents the input Tensors of the model.
fetch_list (list) – This parameter represents the Tensors that need to be returned after the model.
- Returns
-
Program
Example
>>> >>> import paddle >>> import paddle.static as static >>> paddle.enable_static() >>> a = static.data(name='data', shape=[None, 1], dtype='int32') >>> b = a + 1 >>> main_prog = static.default_main_program() >>> ipu_strategy = static.IpuStrategy() >>> ipu_strategy.set_graph_config(num_ipus=1, is_training=True, micro_batch_size=1) >>> ipu_strategy.set_pipelining_config(enable_pipelining=False, batches_per_step=1, enable_gradient_accumulation=False, accumulation_factor=1) >>> ipu_strategy.set_precision_config(enable_fp16=False) >>> program = static.IpuCompiledProgram( ... main_prog, ... ipu_strategy=ipu_strategy).compile([a.name], [b.name])