diff --git a/paddle/fluid/pybind/slice_utils.h b/paddle/fluid/pybind/slice_utils.h index 3d9035114d6db0..49a6866b2cbfbc 100644 --- a/paddle/fluid/pybind/slice_utils.h +++ b/paddle/fluid/pybind/slice_utils.h @@ -609,9 +609,9 @@ static paddle::Tensor dealWithValues(const paddle::Tensor& tensor, tensor.dtype() == phi::DataType::INT16 || tensor.dtype() == phi::DataType::INT8 || tensor.dtype() == phi::DataType::UINT8) { - values->push_back(value_obj_tmp.cast()); + values->push_back(value_obj_tmp.cast()); } else if (tensor.dtype() == phi::DataType::INT64) { - values->push_back(value_obj_tmp.cast()); + values->push_back(value_obj_tmp.cast()); } else if (tensor.dtype() == phi::DataType::BOOL) { values->push_back(value_obj_tmp.cast()); } else if (tensor.dtype() == phi::DataType::COMPLEX64) { diff --git a/python/paddle/base/dygraph/tensor_patch_methods.py b/python/paddle/base/dygraph/tensor_patch_methods.py index 168741e8def167..aed4833188d6c1 100644 --- a/python/paddle/base/dygraph/tensor_patch_methods.py +++ b/python/paddle/base/dygraph/tensor_patch_methods.py @@ -975,7 +975,7 @@ def __array__(self, dtype=None): array = array.astype(dtype) return array - def pre_deal_index(self, item, value=None): + def pre_deal_index(self, item): # since in pybind there is no effiency way to transfer Py_Tuple/Py_List/Py_Range to Tensor # we call this function in python level. item = list(item) if isinstance(item, tuple) else [item] @@ -985,14 +985,14 @@ def pre_deal_index(self, item, value=None): elif isinstance(slice_item, range): item[i] = paddle.to_tensor(list(slice_item)) - return tuple(item), value + return tuple(item) def __getitem__(self, item): - item, _ = pre_deal_index(self, item) + item = pre_deal_index(self, item) return self._getitem_dygraph(item) def __setitem__(self, item, value): - item, value = pre_deal_index(self, item, value) + item = pre_deal_index(self, item) return self._setitem_dygraph(item, value) @framework.dygraph_only