diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index 73a37253828918e48c8139b347fc2319d5a340d2..ba7a1f1ef23f571b87ec76466f0b2ea05a42bd17 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -669,21 +669,24 @@ def unique(x, } out = helper.create_variable_for_type_inference( dtype=x.dtype, stop_gradient=True) + indices = helper.create_variable_for_type_inference( + dtype=attr_dtype, stop_gradient=True) inverse = helper.create_variable_for_type_inference( dtype=attr_dtype, stop_gradient=True) - outputs = {"Out": out, "Index": inverse} + counts = helper.create_variable_for_type_inference( + dtype=attr_dtype, stop_gradient=True) + outputs = { + "Out": out, + "Indices": indices, + "Index": inverse, + "Counts": counts + } outs = [out] if return_index: - indices = helper.create_variable_for_type_inference( - dtype=attr_dtype, stop_gradient=True) - outputs["Indices"] = indices outs.append(indices) if return_inverse: outs.append(inverse) if return_counts: - counts = helper.create_variable_for_type_inference( - dtype=attr_dtype, stop_gradient=True) - outputs["Counts"] = counts outs.append(counts) helper.append_op(