mindspore.ops.print

View Source On Gitee
mindspore.ops.print_(*input_x)[source]

Outputs the inputs to stdout. The outputs are printed to screen by default. It can also be saved in a file by setting the parameter print_file_path in context. Once set, the output will be saved in the file specified by print_file_path. mindspore.parse_print() can be employed to reload the data. For more information, please refer to mindspore.set_context() and mindspore.parse_print(). In Ascend platform with graph mode, can set environment variables MS_DUMP_SLICE_SIZE and MS_DUMP_WAIT_TIME to solve operator execution failure when outputting big tensor or outputting tensor intensively.

Note

In pynative mode, please use python print function. In Ascend platform with graph mode, the bool, int and float would be converted into Tensor to print, and str remains unchanged. This function is used for debugging.

Parameters

input_x (Union[Tensor, bool, int, float, str, tuple, list]) – The inputs of print_. Supports multiple inputs which are separated by ','.

Returns

Invalid value, should be ignored.

Raises

TypeError – If input_x is not one of the following: Tensor, bool, int, float, str, tuple or list.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.ones([2, 1]).astype(np.int32))
>>> y = Tensor(np.ones([2, 2]).astype(np.int32))
>>> result = ops.print_('Print Tensor x and Tensor y:', x, y)
Print Tensor x and Tensor y:
Tensor(shape=[2, 1], dtype=Int32, value=
[[1],
 [1]])
Tensor(shape=[2, 2], dtype=Int32, value=
[[1, 1],
 [1, 1]])