diff --git a/paddle/fluid/pybind/eager_method.cc b/paddle/fluid/pybind/eager_method.cc index 57962c4a1406f..b0c761ebd98b5 100644 --- a/paddle/fluid/pybind/eager_method.cc +++ b/paddle/fluid/pybind/eager_method.cc @@ -70,7 +70,6 @@ typedef SSIZE_T ssize_t; #include "paddle/phi/kernels/funcs/math_function.h" #include "paddle/utils/pybind.h" -PHI_DECLARE_bool(set_to_1d); PHI_DECLARE_bool(use_stride_kernel); namespace paddle { @@ -179,34 +178,7 @@ static PyObject* tensor_method_numpy(TensorObject* self, Py_intptr_t py_strides[paddle::framework::DDim::kMaxRank]; // NOLINT size_t py_rank = tensor_dims.size(); size_t numel = 1; - if (py_rank == 0) { - Py_ssize_t args_num = PyTuple_Size(args); - // true by default - bool set_to_1d = FLAGS_set_to_1d; - if (args_num == (Py_ssize_t)1) { - PyObject* obj = PyTuple_GET_ITEM(args, 0); - if (obj == Py_False) { - set_to_1d = false; - } - } - if (set_to_1d) { - // 0D Tensor hack process to 1D numpy, will remove in release 2.6 - VLOG(0) - << "Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In " - "order to avoid this problem, " - "0D Tensor will be changed to 1D numpy currently, but it's not " - "correct and will be " - "removed in release 2.6. For Tensor contain only one element, " - "Please " - "modify " - " 'Tensor.numpy()[0]' to 'float(Tensor)' as soon as " - "possible, " - "otherwise 'Tensor.numpy()[0]' will raise error in release 2.6."; - py_rank = 1; - py_dims[0] = 1; - py_strides[0] = static_cast(sizeof_dtype * numel); - } - } else if (self->tensor.is_dense_tensor()) { + if (self->tensor.is_dense_tensor()) { auto tensor_stride = self->tensor.strides(); for (int i = static_cast(tensor_dims.size()) - 1; i >= 0; --i) { diff --git a/paddle/fluid/pybind/imperative.cc b/paddle/fluid/pybind/imperative.cc index 8ba56008fb2b0..3092c41d69a37 100644 --- a/paddle/fluid/pybind/imperative.cc +++ b/paddle/fluid/pybind/imperative.cc @@ -64,7 +64,6 @@ limitations under the License. */ #include "paddle/phi/core/compat/arg_map_context.h" #include "paddle/phi/core/type_defs.h" -PHI_DECLARE_bool(set_to_1d); namespace paddle { namespace pybind { diff --git a/paddle/phi/core/flags.cc b/paddle/phi/core/flags.cc index f8da1238d23d8..ddfe195b85ed9 100644 --- a/paddle/phi/core/flags.cc +++ b/paddle/phi/core/flags.cc @@ -743,16 +743,6 @@ PHI_DEFINE_EXPORTED_int32( "less FLAGS_max_inplace_grad_add, than it will be use several grad_add" "instead of sum. Default is 0."); -/** - * Tensor.numpy() has a hack, and this flag can close this hack - * [true]: set 0D Tensor to 1D Numpy - * [false]: not set 0D Tensor to 1D Numpy, close the hack - * - * Now, just set true by default in 2.5 transition time - * which will be removed in future (2.6) . - */ -PHI_DEFINE_EXPORTED_bool(set_to_1d, false, "set 0D Tensor to 1D numpy"); - /** * Debug related FLAG * Name: tracer_mkldnn_ops_on diff --git a/paddle/phi/kernels/funcs/slice_utils.h b/paddle/phi/kernels/funcs/slice_utils.h index a78dcf5419cd3..48a6805a6775c 100644 --- a/paddle/phi/kernels/funcs/slice_utils.h +++ b/paddle/phi/kernels/funcs/slice_utils.h @@ -19,8 +19,6 @@ limitations under the License. */ #include #include "paddle/phi/core/flags.h" -PHI_DECLARE_bool(set_to_1d); - namespace phi { namespace funcs { @@ -205,11 +203,6 @@ inline DDim GetDecreasedDims(const DDim slice_dims, new_shape.push_back(decreased_dims[i]); } } - if (FLAGS_set_to_1d && new_shape.size() == 0) { - // NOTE(zoooo0820): Hack procssing to 1-D, when axes decrease to 0-D in - // slice. This will remove in release 2.6. - new_shape.push_back(1); - } decreased_dims = common::make_ddim(new_shape); } return decreased_dims; diff --git a/paddle/phi/kernels/stride/slice_kernel.cc b/paddle/phi/kernels/stride/slice_kernel.cc index 3981f16ab6c42..25c435707a495 100644 --- a/paddle/phi/kernels/stride/slice_kernel.cc +++ b/paddle/phi/kernels/stride/slice_kernel.cc @@ -20,8 +20,6 @@ #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/slice_utils.h" -PHI_DECLARE_bool(set_to_1d); - namespace phi { template @@ -74,12 +72,6 @@ void SliceStridedKernel(const Context& ctx, new_stride.push_back(output_stride[i]); } } - if (FLAGS_set_to_1d && new_shape.size() == 0) { - // NOTE(zoooo0820): Hack processing to 1-D, when axes decrease to 0-D in - // slice. This will remove in release 2.6. - new_shape.push_back(1); - new_stride.push_back(0); - } output_dims = new_shape; output_stride = new_stride; } diff --git a/paddle/scripts/paddle_build.bat b/paddle/scripts/paddle_build.bat index 11e1d3f7d7054..26b8ed087efb9 100644 --- a/paddle/scripts/paddle_build.bat +++ b/paddle/scripts/paddle_build.bat @@ -737,7 +737,6 @@ for /F %%# in ('wmic os get localdatetime^|findstr 20') do set start=%%# set start=%start:~4,10% set FLAGS_call_stack_level=2 -set FLAGS_set_to_1d=False dir %THIRD_PARTY_PATH:/=\%\install\openblas\lib dir %THIRD_PARTY_PATH:/=\%\install\openblas\bin dir %THIRD_PARTY_PATH:/=\%\install\zlib\bin diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 66a232b0d128a..9be2674830676 100644 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -61,7 +61,6 @@ function init() { # NOTE(chenweihang): For easy debugging, CI displays the C++ error stacktrace by default export FLAGS_call_stack_level=2 - export FLAGS_set_to_1d=False } function cmake_base() { diff --git a/python/paddle/distributed/auto_parallel/static/operators/dist_slice.py b/python/paddle/distributed/auto_parallel/static/operators/dist_slice.py index 0110f54d481a0..d3ab874344dc8 100644 --- a/python/paddle/distributed/auto_parallel/static/operators/dist_slice.py +++ b/python/paddle/distributed/auto_parallel/static/operators/dist_slice.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle from ..utils import compute_compatible_dim_mapping, is_dim_shard from .common import ( @@ -72,14 +71,7 @@ def is_output_compatible(self, dist_op): if i not in decrease_axis: ref_indices.append(i) if ref_indices == []: - # NOTE(zoooo0820): When all axes are decreased, the output will be 1-D - # with FLAGS_set_to_1d=True. - if paddle.get_flags('FLAGS_set_to_1d')['FLAGS_set_to_1d']: - assert len(out_dims_mapping) == 1 - if is_dim_shard(out_dims_mapping[0]): - return False - else: - assert len(out_dims_mapping) == 0 + assert len(out_dims_mapping) == 0 else: for i in range(len(out_dims_mapping)): ref_index = ref_indices[i] @@ -149,11 +141,6 @@ def update_dims_mapping(self, dist_op): ref_indices.append(i) if ref_dims_mapping == []: - # NOTE(zoooo0820): When all axes are decreased, the output will be 1-D - # with FLAGS_set_to_1d=True. - if paddle.get_flags('FLAGS_set_to_1d')['FLAGS_set_to_1d']: - ref_dims_mapping = [-1] - assert ref_dims_mapping[0] == out_dims_mapping[0] assert len(ref_dims_mapping) == len(out_dims_mapping) changed = False else: