Get readable debug string of Program. .. note:: If you want to get the debug string in protobuf format, please use :code:`to_string` method. Args: skip_op_callstack(bool): whether to skip parsing Operator's attribute op_c
(self, skip_op_callstack=True)
| 6423 | return self._to_readable_code() |
| 6424 | |
| 6425 | def _to_readable_code(self, skip_op_callstack=True): |
| 6426 | """ |
| 6427 | Get readable debug string of Program. |
| 6428 | |
| 6429 | .. note:: |
| 6430 | If you want to get the debug string in protobuf format, |
| 6431 | please use :code:`to_string` method. |
| 6432 | |
| 6433 | Args: |
| 6434 | skip_op_callstack(bool): whether to skip parsing Operator's attribute |
| 6435 | op_callstack, default value is True |
| 6436 | |
| 6437 | Returns: |
| 6438 | string: The formatted Program string. |
| 6439 | |
| 6440 | Examples: |
| 6441 | .. code-block:: pycon |
| 6442 | |
| 6443 | >>> import paddle |
| 6444 | >>> import paddle.static as static |
| 6445 | |
| 6446 | >>> paddle.enable_static() |
| 6447 | |
| 6448 | >>> cur_program = static.Program() |
| 6449 | >>> cur_block = cur_program.current_block() |
| 6450 | >>> new_var = cur_block.create_var( |
| 6451 | ... name="X", |
| 6452 | ... shape=[-1, 23, 48], |
| 6453 | ... dtype="float32", |
| 6454 | ... ) |
| 6455 | >>> new_op = cur_block.append_op( |
| 6456 | ... type="abs", |
| 6457 | ... inputs={"X": [new_var]}, |
| 6458 | ... outputs={"Out": [new_var]}, |
| 6459 | ... ) |
| 6460 | >>> print(cur_program._to_readable_code()) |
| 6461 | """ |
| 6462 | assert isinstance(skip_op_callstack, bool), ( |
| 6463 | f"skip_op_callstack parameter's type is error, expect bool, received {type(skip_op_callstack)}" |
| 6464 | ) |
| 6465 | program_str = "" |
| 6466 | for block in self.blocks: |
| 6467 | program_str += block._to_readable_code(skip_op_callstack) |
| 6468 | program_str += "\n" |
| 6469 | return program_str |
| 6470 | |
| 6471 | def to_string(self, throw_on_error, with_details=False): |
| 6472 | """ |
no test coverage detected