From 31b77d42d688b6cbffd0fbd260be9dfddb66ffef Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Wed, 15 Jun 2022 12:03:57 -0700 Subject: [PATCH] Remove reference to numpy.typing (#4277) * bump version to 1.12.0 (#4209) * bump version to 1.12.0 Signed-off-by: Ettore Tiotto * Remove trailing white space Signed-off-by: Ettore Tiotto Co-authored-by: Chun-Wei Chen Signed-off-by: Justin Chu * Update numpy_helper.py Signed-off-by: Justin Chu * Update numpy_helper.py Signed-off-by: Justin Chu * Update onnx/numpy_helper.py Co-authored-by: Chun-Wei Chen Signed-off-by: Justin Chu * Update numpy_helper.py Signed-off-by: Justin Chu * syntax Signed-off-by: Justin Chu Co-authored-by: Ettore Tiotto Co-authored-by: Chun-Wei Chen --- onnx/numpy_helper.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/onnx/numpy_helper.py b/onnx/numpy_helper.py index d234468dc23..19052e8f1bd 100644 --- a/onnx/numpy_helper.py +++ b/onnx/numpy_helper.py @@ -1,20 +1,19 @@ # SPDX-License-Identifier: Apache-2.0 import sys +from typing import Any, Dict, List, Optional, Sequence, Union import numpy as np # type: ignore -import numpy.typing as nptyping # type: ignore -from onnx import TensorProto, MapProto, SequenceProto, OptionalProto -from onnx import mapping, helper + +from onnx import MapProto, OptionalProto, SequenceProto, TensorProto, mapping from onnx.external_data_helper import load_external_data_for_tensor, uses_external_data -from typing import Sequence, Any, Optional, List, Dict -def combine_pairs_to_complex(fa: Sequence[int]) -> Sequence[np.complex64]: +def combine_pairs_to_complex(fa: Sequence[int]) -> List[complex]: return [complex(fa[i * 2], fa[i * 2 + 1]) for i in range(len(fa) // 2)] -def bfloat16_to_float32(data: np.ndarray, dims: nptyping._ShapeLike) -> np.ndarray: +def bfloat16_to_float32(data: np.ndarray, dims: Union[int, Sequence[int]]) -> np.ndarray: """Converts ndarray of bf16 (as uint32) to f32 (as uint32).""" shift = lambda x: x << 16 # noqa: E731 return shift(data.astype(np.int32)).reshape(dims).view(np.float32)