- Notifications
You must be signed in to change notification settings - Fork0
Implements ArrayAPI#17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
27 commits Select commitHold shift + click to select a range
945749c
rename ArrayApi into BaseArrayApi
xadupre38c3c0e
Implements ArrayAPI
xadupre178185f
Merge branch 'main' of https://github.com/sdpython/onnx-array-api int…
xadupref0d4eba
documentation
xadupre0ffa4b4
ci
xadupre293c570
fix ci
xaduprecaf2324
xi
xadupre768eb85
ci
xadupre692774e
ci
xadupre5c7dae1
ci
xadupre1a1cd35
ci
xadupreda3a7c8
many changes to follow the Array API
xaduprec600890
more changes
xadupre535cc4a
fix unit test
xadupre5a07911
fix ci
xadupre3481d27
ci
xadupre1990fe8
api
xadupree0ca8c4
ci
xadupre1e218b5
improvments
xadupree344011
refactorign
xadupre178e3e9
fix asarray
xadupre550d0dc
new udpates
sdpython0169b85
fix two bugs
xaduprecb11e55
Add one unit test for empty input
xaduprecaa99a7
fix all when shape is empty and has one dimension
xadupre8945d16
fix missing return
xadupre7a979a2
remove the full tests
xadupreFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
fix asarray
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit178e3e933dbfc64cc6b4a18cd087ad6d1f06d59a
There are no files selected for viewing
4 changes: 4 additions & 0 deletionsazure-pipelines.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletionsonnx_array_api/array_api/_onnx_common.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import Any, Optional | ||
import numpy as np | ||
from ..npx.npx_types import DType | ||
from ..npx.npx_array_api import BaseArrayApi | ||
from ..npx.npx_functions import ( | ||
copy as copy_inline, | ||
) | ||
def template_asarray( | ||
TEagerTensor: type, | ||
a: Any, | ||
dtype: Optional[DType] = None, | ||
order: Optional[str] = None, | ||
like: Any = None, | ||
copy: bool = False, | ||
) -> Any: | ||
""" | ||
Converts anything into an array. | ||
""" | ||
if order not in ("C", None): | ||
raise NotImplementedError(f"asarray is not implemented for order={order!r}.") | ||
if like is not None: | ||
raise NotImplementedError( | ||
f"asarray is not implemented for like != None (type={type(like)})." | ||
) | ||
if isinstance(a, BaseArrayApi): | ||
if copy: | ||
if dtype is None: | ||
return copy_inline(a) | ||
return copy_inline(a).astype(dtype=dtype) | ||
if dtype is None: | ||
return a | ||
return a.astype(dtype=dtype) | ||
if isinstance(a, int): | ||
v = TEagerTensor(np.array(a, dtype=np.int64)) | ||
elif isinstance(a, float): | ||
v = TEagerTensor(np.array(a, dtype=np.float32)) | ||
elif isinstance(a, bool): | ||
v = TEagerTensor(np.array(a, dtype=np.bool_)) | ||
elif isinstance(a, str): | ||
v = TEagerTensor(np.array(a, dtype=np.str_)) | ||
else: | ||
raise RuntimeError(f"Unexpected type {type(a)} for the first input.") | ||
if dtype is not None: | ||
vt = v.astype(dtype=dtype) | ||
else: | ||
vt = v | ||
return vt |
36 changes: 4 additions & 32 deletionsonnx_array_api/array_api/onnx_numpy.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletionsonnx_array_api/array_api/onnx_ort.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
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.