From ba51043f7ec843cd98f9e84e45d0121570de3990 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 27 Dec 2019 17:29:57 +0800 Subject: [PATCH] remove parameter block in to_variable, test=develop (#21933) --- python/paddle/fluid/dygraph/base.py | 9 ++++----- python/paddle/fluid/layer_helper_base.py | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/python/paddle/fluid/dygraph/base.py b/python/paddle/fluid/dygraph/base.py index af0e79929f..674c556daa 100644 --- a/python/paddle/fluid/dygraph/base.py +++ b/python/paddle/fluid/dygraph/base.py @@ -172,20 +172,19 @@ def _print_debug_msg(parameter_list, limit=5, is_test=False): return unique_name_size, tracer_var_size, alive_cpp_var_size -# TODO(zhiqiu): Param 'block' should be deprecated, since block is meaningless in dygraph @framework.dygraph_only -def to_variable(value, block=None, name=None, zero_copy=None): +def to_variable(value, name=None, zero_copy=None): """ The API will create a ``Variable`` object from numpy\.ndarray or Variable object. Parameters: - value(ndarray): The numpy\.ndarray object that needs to be converted, it can be multi-dimension, and the data type is one of numpy\.{float16, float32, float64, int16, int32, int64, uint8, uint16}. - block(fluid.Block, optional): Which block this variable will be in. Default: None. + value(ndarray|Variable): The numpy\.ndarray or Variable object that needs to be converted, it can be multi-dimension, and the data type is one of numpy\.{float16, float32, float64, int16, int32, int64, uint8, uint16}. name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` zero_copy(bool, optional): Whether to share memory with the input numpy array. This parameter only works with CPUPlace and will be set to True when it is None. Default: None. Returns: - Variable: ``Tensor`` created from the specified numpy\.ndarray object, data type and shape is the same as ``value`` . + Variable: If ``value`` is a numpy\.ndarray object, return ``Tensor`` created from the specified numpy\.ndarray object, which has same data type and shape with ``value``. If ``value`` is a Variable object, just return ``value``. + Examples: diff --git a/python/paddle/fluid/layer_helper_base.py b/python/paddle/fluid/layer_helper_base.py index adfeedac31..3140a84c09 100644 --- a/python/paddle/fluid/layer_helper_base.py +++ b/python/paddle/fluid/layer_helper_base.py @@ -50,7 +50,6 @@ class LayerHelperBase(object): Parameters: value(ndarray): The numpy\.ndarray object that needs to be converted, it can be multi-dimension, and the data type is one of numpy\.{float16, float32, float64, int16, int32, int64, uint8, uint16}. - block(fluid.Block, optional): Which block this variable will be in. Default: None. name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` Returns: