Get all Tensors from this Program. A iterable object is returned. Returns: iterable Tensors: The Generator will yield every Tensor in this program. Examples: .. code-block:: pycon >>> # doctest: +SKIP("This has diff in xdoctest env"
(self)
| 7441 | dst_op.struct_name = src_op.struct_name |
| 7442 | |
| 7443 | def list_vars(self): |
| 7444 | """ |
| 7445 | Get all Tensors from this Program. A iterable object is returned. |
| 7446 | |
| 7447 | Returns: |
| 7448 | iterable Tensors: The Generator will yield every Tensor in this program. |
| 7449 | |
| 7450 | Examples: |
| 7451 | .. code-block:: pycon |
| 7452 | |
| 7453 | >>> # doctest: +SKIP("This has diff in xdoctest env") |
| 7454 | >>> import paddle |
| 7455 | >>> import paddle.static as static |
| 7456 | |
| 7457 | >>> paddle.enable_static() |
| 7458 | |
| 7459 | >>> prog = static.default_main_program() |
| 7460 | >>> img = static.data(name='img', shape=[None, 1, 28, 28], dtype='float32') |
| 7461 | >>> label = static.data(name='label', shape=[None, 1], dtype='int64') |
| 7462 | >>> for var in prog.list_vars(): |
| 7463 | ... print(var) |
| 7464 | |
| 7465 | >>> # var img : DENSE_TENSOR.shape(-1, 1, 28, 28).dtype(float32).stop_gradient(True) |
| 7466 | >>> # var label : DENSE_TENSOR.shape(-1, 1).dtype(int64).stop_gradient(True) |
| 7467 | """ |
| 7468 | for each_block in self.blocks: |
| 7469 | yield from list(each_block.vars.values()) |
| 7470 | |
| 7471 | def all_parameters(self): |
| 7472 | """ |