Thanks to visit codestin.com
Credit goes to github.com

Skip to content

xp.eye(..., device=device) has not effect when xp is cupy #337

Open
@PascalCarrivain

Description

@PascalCarrivain

Dear all,

I run the following command when xp is cupy

# cupy
x = cupy.asarray([1.0] * 3)
xp = array_api_compat.array_namespace(x)
E = xp.eye(3, 3, k=0, dtype='float64', device=1)
print(E.device)
with xp.cuda.Device(1):
    E = xp.eye(3, 3, k=0, dtype='float64', device=1)
    print(E.device)
# torch
x = torch.as_tensor([1.0] * 3)
xp = array_api_compat.array_namespace(x)
E = xp.eye(3, 3, k=0, dtype=torch.float64, device='cuda:1')
print(E.device)

and I get the result:

<CUDA Device 0>
<CUDA Device 1>
cuda:1

It seems that device argument of xp.eye has no effect here when xp is cupy.
It seems to work well when xp is torch.
Did I miss something?

Thank you.

array-api-compat 1.12.0
cupy-cuda12x 13.4.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions