Get readable debug string of Operator. .. 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_
(self, skip_op_callstack=True)
| 3580 | return _debug_string_(proto, throw_on_error) |
| 3581 | |
| 3582 | def _to_readable_code(self, skip_op_callstack=True): |
| 3583 | """ |
| 3584 | Get readable debug string of Operator. |
| 3585 | |
| 3586 | .. note:: |
| 3587 | If you want to get the debug string in protobuf format, |
| 3588 | please use :code:`to_string` method. |
| 3589 | |
| 3590 | Args: |
| 3591 | skip_op_callstack(bool): whether to skip parsing Operator's attribute |
| 3592 | op_callstack, default value is True |
| 3593 | |
| 3594 | Returns: |
| 3595 | string: The formatted Operator string. |
| 3596 | |
| 3597 | Examples: |
| 3598 | .. code-block:: pycon |
| 3599 | |
| 3600 | >>> import paddle |
| 3601 | |
| 3602 | >>> paddle.enable_static() |
| 3603 | >>> cur_program = paddle.static.Program() |
| 3604 | >>> cur_block = cur_program.current_block() |
| 3605 | >>> var = cur_block.create_var( |
| 3606 | ... name="X", |
| 3607 | ... shape=[-1, 23, 48], |
| 3608 | ... dtype="float32", |
| 3609 | ... ) |
| 3610 | >>> new_op = cur_block.append_op( |
| 3611 | ... type="abs", |
| 3612 | ... inputs={"X": [var]}, |
| 3613 | ... outputs={"Out": [var]}, |
| 3614 | ... ) |
| 3615 | >>> print(new_op._to_readable_code()) |
| 3616 | """ |
| 3617 | assert isinstance(skip_op_callstack, bool), ( |
| 3618 | f"skip_op_callstack parameter's type is error, expect bool, received {type(skip_op_callstack)}" |
| 3619 | ) |
| 3620 | outputs_str = "{" |
| 3621 | for i in range(0, len(self.output_names)): |
| 3622 | outputs_str += f"{self.output_names[i]}=" |
| 3623 | o = self.output(self.output_names[i]) |
| 3624 | outputs_str += f"{o}" |
| 3625 | if i != len(self.output_names) - 1: |
| 3626 | outputs_str += ", " |
| 3627 | outputs_str += "}" |
| 3628 | |
| 3629 | inputs_str = "{" |
| 3630 | for i in range(0, len(self.input_names)): |
| 3631 | inputs_str += f"{self.input_names[i]}=" |
| 3632 | o = self.input(self.input_names[i]) |
| 3633 | inputs_str += f"{o}" |
| 3634 | |
| 3635 | if i != len(self.input_names) - 1: |
| 3636 | inputs_str += ", " |
| 3637 | inputs_str += "}" |
| 3638 | |
| 3639 | attr_names = sorted(self.attr_names) |
no test coverage detected