Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Bug fixes
PR changes
Others
Describe
monkey_patch_math_varbase函数需要调用两次才能将所有的method patch到Tensor上。修改这个bug。
目前,EagerTensor和VarBase拥有的method基本一致,仍存在少量diff:
目前,dir(core.eager.EagerTensor())的数据如下:
['T', 'add', 'and', 'array', 'array_ufunc', 'bool', 'class', 'deepcopy', 'delattr', 'dir', 'div', 'doc', 'eq', 'float', 'floordiv', 'format', 'ge', 'getattribute', 'getitem', 'gt', 'hash', 'index', 'init', 'init_subclass', 'int', 'invert', 'le', 'len', 'long', 'lt', 'matmul', 'mod', 'module', 'mul', 'ne', 'neg', 'new', 'nonzero', 'or', 'pow', 'radd', 'rdiv', 'reduce', 'reduce_ex', 'repr', 'rmul', 'rpow', 'rsub', 'rtruediv', 'setattr', 'setitem', 'sizeof', 'str', 'sub', 'subclasshook', 'truediv', 'xor', 'clear_gradient', 'copy_to', 'grad_ivar', 'is_initialized', 'place_str', 'to', 'to_static_var', 'zero_grads', 'abs', 'acos', 'acosh', 'add', 'add', 'add_n', 'addmm', 'all', 'allclose', 'amax', 'amin', 'angle', 'any', 'argmax', 'argmin', 'argsort', 'as_complex', 'as_real', 'asin', 'asinh', 'astype', 'atan', 'atanh', 'backward', 'bincount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'block', 'bmm', 'broadcast_shape', 'broadcast_tensors', 'broadcast_to', 'cast', 'ceil', 'ceil', 'cholesky', 'cholesky_solve', 'chunk', 'clear_grad', 'clear_gradient', 'clip', 'clip', 'concat', 'cond', 'conj', 'copy', 'cos', 'cosh', 'cov', 'cross', 'cumprod', 'cumsum', 'deg2rad', 'diagonal', 'diff', 'digamma', 'dim', 'dist', 'divide', 'dot', 'dtype', 'eig', 'eigvals', 'eigvalsh', 'equal', 'equal_all', 'erf', 'erfinv', 'erfinv', 'exp', 'exp', 'expand', 'expand_as', 'exponential', 'flatten', 'flatten', 'flip', 'floor', 'floor_', 'floor_divide', 'floor_mod', 'fmax', 'fmin', 'gather', 'gather_nd', 'gcd', 'grad', 'gradient', 'greater_equal', 'greater_than', 'histogram', 'imag', 'increment', 'index_sample', 'index_select', 'inner', 'inplace_version', 'inverse', 'is_complex', 'is_empty', 'is_floating_point', 'is_integer', 'is_tensor', 'isclose', 'isfinite', 'isinf', 'isnan', 'item', 'kron', 'kthvalue', 'lcm', 'lerp', 'lerp_', 'less_equal', 'less_than', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logit', 'logsumexp', 'lstsq', 'lu', 'lu_unpack', 'masked_select', 'matmul', 'matrix_power', 'max', 'maximum', 'mean', 'median', 'min', 'minimum', 'mm', 'mod', 'mode', 'moveaxis', 'multi_dot', 'multiplex', 'multiply', 'mv', 'name', 'nansum', 'ndim', 'ndimension', 'neg', 'nonzero', 'norm', 'not_equal', 'numel', 'numpy', 'outer', 'persistable', 'place', 'pow', 'prod', 'put_along_axis', 'put_along_axis_', 'qr', 'quantile', 'rad2deg', 'rank', 'real', 'reciprocal', 'reciprocal_', 'register_hook', 'remainder', 'repeat_interleave', 'reshape', 'reshape_', 'retain_grads', 'reverse', 'roll', 'rot90', 'round', 'round_', 'rsqrt', 'rsqrt_', 'scale', 'scale_', 'scatter', 'scatter_', 'scatter_nd', 'scatter_nd_add', 'set_value', 'shape', 'shard_index', 'sign', 'sin', 'sinh', 'size', 'slice', 'solve', 'sort', 'split', 'sqrt', 'sqrt_', 'square', 'squeeze', 'squeeze_', 'stack', 'stanh', 'std', 'stop_gradient', 'strided_slice', 'subtract', 'subtract_', 'sum', 't', 'take_along_axis', 'tanh', 'tanh_', 'tensordot', 'tile', 'topk', 'trace', 'transpose', 'trunc', 'unbind', 'uniform_', 'unique', 'unique_consecutive', 'unsqueeze', 'unsqueeze_', 'unstack', 'var', 'where']
dir(core.VarBase())的数据如下:
['T', 'add', 'and', 'array', 'array_ufunc', 'bool', 'class', 'deepcopy', 'delattr', 'dir', 'div', 'doc', 'eq', 'float', 'floordiv', 'format', 'ge', 'getattribute', 'getitem', 'gt', 'hash', 'index', 'init', 'init_subclass', 'int', 'invert', 'le', 'len', 'long', 'lt', 'matmul', 'mod', 'module', 'mul', 'ne', 'neg', 'new', 'nonzero', 'or', 'pow', 'radd', 'rdiv', 'reduce', 'reduce_ex', 'repr', 'rmul', 'rpow', 'rsub', 'rtruediv', 'setattr', 'setitem', 'setitem_varbase', 'sizeof', 'str', 'sub', 'subclasshook', 'truediv', 'xor', '_alive_vars', '_allreduce', '_bump_inplace_version', '_clear', 'copy_gradient_from', 'copy_to', 'getitem_from_offset', 'getitem_index_not_tensor', 'grad_ivar', 'grad_name', 'grad_value', 'gradient_set_empty', 'inplace_version', 'is_gradient_set_empty', 'is_shared_buffer_with', 'is_sparse', 'numel', 'offset', 'place_str', 'register_backward_hook', 'register_grad_hook', 'register_void_function_post_hook', 'remove_grad_hook', 'reset_grad_inplace_version', 'set_grad_ivar', 'set_grad_type', 'share_buffer_to', 'share_memory', 'slice', 'to', 'to_static_var', 'abs', 'acos', 'acosh', 'add', 'add', 'add_n', 'addmm', 'all', 'allclose', 'amax', 'amin', 'angle', 'any', 'argmax', 'argmin', 'argsort', 'as_complex', 'as_real', 'asin', 'asinh', 'astype', 'atan', 'atanh', 'backward', 'bincount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'block', 'bmm', 'broadcast_shape', 'broadcast_tensors', 'broadcast_to', 'cast', 'ceil', 'ceil', 'cholesky', 'cholesky_solve', 'chunk', 'clear_grad', 'clear_gradient', 'clip', 'clip', 'clone', 'concat', 'cond', 'conj', 'copy', 'cos', 'cosh', 'cov', 'cpu', 'cross', 'cuda', 'cumprod', 'cumsum', 'deg2rad', 'detach', 'diagonal', 'diff', 'digamma', 'dim', 'dist', 'divide', 'dot', 'dtype', 'eig', 'eigvals', 'eigvalsh', 'element_size', 'equal', 'equal_all', 'erf', 'erfinv', 'erfinv', 'exp', 'exp', 'expand', 'expand_as', 'exponential', 'fill', 'fill_diagonal', 'fill_diagonal_tensor', 'fill_diagonal_tensor', 'flatten', 'flatten', 'flip', 'floor', 'floor', 'floor_divide', 'floor_mod', 'fmax', 'fmin', 'gather', 'gather_nd', 'gcd', 'grad', 'gradient', 'greater_equal', 'greater_than', 'histogram', 'imag', 'increment', 'index_sample', 'index_select', 'inner', 'inplace_version', 'inverse', 'is_complex', 'is_empty', 'is_floating_point', 'is_integer', 'is_leaf', 'is_tensor', 'isclose', 'isfinite', 'isinf', 'isnan', 'item', 'kron', 'kthvalue', 'lcm', 'lerp', 'lerp', 'less_equal', 'less_than', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logit', 'logsumexp', 'lstsq', 'lu', 'lu_unpack', 'masked_select', 'matmul', 'matrix_power', 'max', 'maximum', 'mean', 'median', 'min', 'minimum', 'mm', 'mod', 'mode', 'moveaxis', 'multi_dot', 'multiplex', 'multiply', 'mv', 'name', 'nansum', 'ndim', 'ndimension', 'neg', 'nonzero', 'norm', 'not_equal', 'numel', 'numpy', 'outer', 'persistable', 'pin_memory', 'place', 'pow', 'prod', 'put_along_axis', 'put_along_axis', 'qr', 'quantile', 'rad2deg', 'rank', 'real', 'reciprocal', 'reciprocal', 'register_hook', 'remainder', 'repeat_interleave', 'reshape', 'reshape', 'reverse', 'roll', 'rot90', 'round', 'round', 'rsqrt', 'rsqrt', 'scale', 'scale', 'scatter', 'scatter', 'scatter_nd', 'scatter_nd_add', 'set_value', 'shape', 'shard_index', 'sign', 'sin', 'sinh', 'size', 'slice', 'solve', 'sort', 'split', 'sqrt', 'sqrt', 'square', 'squeeze', 'squeeze', 'stack', 'stanh', 'std', 'stop_gradient', 'strided_slice', 'subtract', 'subtract', 'sum', 't', 'take_along_axis', 'tanh', 'tanh', 'tensordot', 'tile', 'tolist', 'topk', 'trace', 'transpose', 'trunc', 'type', 'unbind', 'uniform', 'unique', 'unique_consecutive', 'unsqueeze', 'unsqueeze', 'unstack', 'value', 'var', 'where', 'zero']