Skip to content

Commit

Permalink
Remove reference to numpy.typing (#4277)
Browse files Browse the repository at this point in the history
* bump version to 1.12.0 (#4209)

* bump version to 1.12.0

Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com>

* Remove trailing white space

Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com>

Co-authored-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Justin Chu <justinchu@microsoft.com>

* Update numpy_helper.py

Signed-off-by: Justin Chu <justinchu@microsoft.com>

* Update numpy_helper.py

Signed-off-by: Justin Chu <justinchu@microsoft.com>

* Update onnx/numpy_helper.py

Co-authored-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Justin Chu <justinchu@microsoft.com>

* Update numpy_helper.py

Signed-off-by: Justin Chu <justinchu@microsoft.com>

* syntax

Signed-off-by: Justin Chu <justinchu@microsoft.com>

Co-authored-by: Ettore Tiotto <etiotto@gmail.com>
Co-authored-by: Chun-Wei Chen <jacky82226@gmail.com>
  • Loading branch information
3 people committed Jun 15, 2022
1 parent 805ae1e commit 31b77d4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions onnx/numpy_helper.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 31b77d4

Please sign in to comment.