Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add paddle support #206

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refine more code
  • Loading branch information
HydrogenSulfate committed Nov 26, 2024
commit a7163f903796684d6f25cb420d72aaadb416433c
3 changes: 1 addition & 2 deletions array_api_compat/paddle/_info.py
Original file line number Diff line number Diff line change
@@ -170,8 +170,7 @@ def _dtypes(self, kind):
int32 = paddle.int32
int64 = paddle.int64
uint8 = paddle.uint8
# uint16, uint32, and uint64 are present in newer versions of pytorch,
# but they aren't generally supported by the array API functions, so
# uint16, uint32, and uint64 are not fully supported in paddle,
# we omit them from this function.
float32 = paddle.float32
float64 = paddle.float64
5 changes: 2 additions & 3 deletions array_api_compat/paddle/linalg.py
Original file line number Diff line number Diff line change
@@ -28,11 +28,10 @@
from ._aliases import matmul, matrix_transpose, tensordot

# Note: paddle.linalg.cross does not default to axis=-1 (it defaults to the
# first axis with size 3), see https://github.com/pytorch/pytorch/issues/58743

# first axis with size 3)

# paddle.cross also does not support broadcasting when it would add new
# dimensions https://github.com/pytorch/pytorch/issues/39656
# dimensions
def cross(x1: array, x2: array, /, *, axis: int = -1) -> array:
x1, x2 = _fix_promotion(x1, x2, only_scalar=False)
if not (-min(x1.ndim, x2.ndim) <= axis < max(x1.ndim, x2.ndim)):
2 changes: 1 addition & 1 deletion tests/test_array_namespace.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import sys
import warnings

# import jax
import jax
import numpy as np
import pytest
import torch
@@ -138,7 +138,7 @@
assert array_namespace(a, True) == xp
assert array_namespace(a, None) == xp

def test_python_scalars():

Check failure on line 141 in tests/test_array_namespace.py

GitHub Actions / check-ruff

Ruff (F811)

tests/test_array_namespace.py:141:5: F811 Redefinition of unused `test_python_scalars` from line 125
a = paddle.to_tensor([1, 2])
xp = import_("paddle", wrapper=True)