From 412d1f0cdceccd9dc2d77df6f1648a1f08d5b0f8 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Tue, 26 Jan 2021 11:51:39 +0800 Subject: [PATCH] fix(mge/tensor): implement abtract method to fix lint errors GitOrigin-RevId: d53f2eac6afc24f6b14b922f1d55f4821659ee98 --- imperative/python/megengine/tensor.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/imperative/python/megengine/tensor.py b/imperative/python/megengine/tensor.py index 19979d45..43b0c5ba 100644 --- a/imperative/python/megengine/tensor.py +++ b/imperative/python/megengine/tensor.py @@ -6,9 +6,7 @@ # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - -import collections +from typing import Union import numpy as np @@ -53,7 +51,7 @@ class Tensor(_Tensor, ArrayMethodMixin): return obj @property - def shape(self): + def shape(self) -> Union[tuple, "Tensor"]: shape = super().shape if shape == () or not use_symbolic_shape(): return shape @@ -63,6 +61,16 @@ class Tensor(_Tensor, ArrayMethodMixin): def _tuple_shape(self): return super().shape + @property + def dtype(self) -> np.dtype: + return super().dtype + + def numpy(self) -> np.ndarray: + return super().numpy() + + def _reset(self, other): + super()._reset(other) + def __repr__(self): piece = "Tensor(" with np.printoptions(precision=4, suppress=True): -- GitLab