mindspore.nn.rearrange_inputs
- mindspore.nn.rearrange_inputs(func)[source]
This decorator is used to rearrange the inputs according to its _indexes attributes which is specified by the set_indexes method.
Examples
>>> class RearrangeInputsExample: ... def __init__(self): ... self._indexes = None ... ... @property ... def indexes(self): ... return getattr(self, '_indexes', None) ... ... def set_indexes(self, indexes): ... self._indexes = indexes ... return self ... ... @rearrange_inputs ... def update(self, *inputs): ... return inputs >>> >>> rearrange_inputs_example = RearrangeInputsExample().set_indexes([1, 0]) >>> outs = rearrange_inputs_example.update(5, 9) >>> print(outs) (9, 5)
- Parameters
func (Callable) – A candidate function to be wrapped whose input will be rearranged.
- Returns
Callable, used to exchange metadata between functions.