Skip to content

Commit

Permalink
cherry pick PR 4277, make RC5 for testing (#4280)
Browse files Browse the repository at this point in the history
  • Loading branch information
liqunfu authored Jun 15, 2022
1 parent b2845aa commit 5c41db8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0rc4
1.12.0rc5
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 5c41db8

Please sign in to comment.