mindspore.ops.Partial
- class mindspore.ops.Partial[source]
Makes a partial function instance. Partial function can be used to derived specialized functions from general functions by fixing the value of certain number of arguments.
- Inputs:
args (Union[FunctionType, Tensor]) - The function and bind arguments.
- Outputs:
FunctionType, partial function bound with arguments.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> from mindspore import Tensor >>> import mindspore.ops as ops >>> def show_input(x, y, z): ... return x, y, z >>> partial = ops.Partial() >>> partial_show_input = partial(show_input, Tensor(1)) >>> output1 = partial_show_input(Tensor(2), Tensor(3)) >>> print(output1) (Tensor(shape=[], dtype=Int64, value= 1), Tensor(shape=[], dtype=Int64, value= 2), Tensor(shape=[], dtype=Int64, value= 3)) >>> output2 = partial_show_input(Tensor(3), Tensor(4)) >>> print(output2) (Tensor(shape=[], dtype=Int64, value= 1), Tensor(shape=[], dtype=Int64, value= 3), Tensor(shape=[], dtype=Int64, value= 4))