default_main_program

paddle.static. default_main_program ( ) [source]

This API can be used to get default main program which store the descriptions of Ops and tensors.

For example z = paddle.add(x, y) will create a new add Op and a new z tensor, and they will be recorded in default main program .

The default main program is the default value for Program parameter in a lot of APIs. For example, the Executor.run() will execute the default_main_program when the program is not specified.

If you want to switch the default main program, you can use api_paddle_fluid_framework_program_guard .

Returns

A Program which holding the descriptions of OPs and tensors in the network.

Return type

Program

Examples

import paddle

paddle.enable_static()
# Sample Network:
x = paddle.static.data(name='x', shape=[100, 100], dtype='float32')
y = paddle.static.data(name='x', shape=[100, 100], dtype='float32')
out = paddle.add(x, y)

#print the number of blocks in the program, 1 in this case
print(paddle.static.default_main_program().num_blocks) # 1
#print the default_main_program
print(paddle.static.default_main_program())

Used in the guide/tutorials