forked from mindspore-Ecosystem/mindspore
!1366 InvertPermutation support 1-d tensor input
Merge pull request !1366 from jiangjinsheng/issue_invert
This commit is contained in:
commit
af6a8c1786
|
@ -905,9 +905,11 @@ class InvertPermutation(PrimitiveWithInfer):
|
|||
values can not be negative.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (tuple[int]) - The input tuple is constructed by multiple
|
||||
- **input_x** (Union(tuple[int], Tensor[int])) - The input tuple is constructed by multiple
|
||||
integers, i.e., :math:`(y_1, y_2, ..., y_S)` representing the indices.
|
||||
The values must include 0. There can be no duplicate values or negative values.
|
||||
If the input is Tensor, it must be 1-d and the dtype is int.
|
||||
|
||||
|
||||
Outputs:
|
||||
tuple[int]. the lenth is same as input.
|
||||
|
@ -926,7 +928,11 @@ class InvertPermutation(PrimitiveWithInfer):
|
|||
def __infer__(self, x):
|
||||
x_shp = x['shape']
|
||||
x_value = x['value']
|
||||
validator.check_value_type("shape", x_shp, [tuple], self.name)
|
||||
validator.check_value_type("shape", x_shp, [tuple, list], self.name)
|
||||
if mstype.issubclass_(x['dtype'], mstype.tensor):
|
||||
validator.check('x dimension', len(x_shp), '', 1, Rel.EQ, self.name)
|
||||
validator.check_type_same({'x dtype': x['dtype']}, mstype.int_type, self.name)
|
||||
x_value = [int(i) for i in x_value.asnumpy()]
|
||||
z = [x_value[i] for i in range(len(x_value))]
|
||||
z.sort()
|
||||
|
||||
|
|
Loading…
Reference in New Issue