default_main_program¶
- paddle.static. default_main_program ( ) [source]
-
This API can be used to get
default main programwhich store the descriptions of Ops and tensors.For example
z = paddle.add(x, y)will create a newaddOp and a newztensor, and they will be recorded indefault main program.The
default main programis the default value forProgramparameter in a lot of APIs. For example, theExecutor.run()will execute thedefault_main_programwhen 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
Programwhich 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())
