Skip to content

[BUG] Array::get_backend() can never return OPENCL #387

Description

@phil-opp

src/core/array.rs:392-404:

match (err_val, ret_val) {
    (0, 1) => Backend::CPU,
    (0, 2) => Backend::CUDA,
    (0, 3) => Backend::OPENCL,
    _ => Backend::DEFAULT,
}

af_backend is a bit-flag enum, not sequential (include/af/defines.h:414-417, v3.8.0):

AF_BACKEND_DEFAULT = 0,
AF_BACKEND_CPU     = 1,
AF_BACKEND_CUDA    = 2,
AF_BACKEND_OPENCL  = 4

There is no backend with value 3. An OpenCL-created array returns 4, falls through to the wildcard, and is reported as Backend::DEFAULT.

Fix: (0, 4) => Backend::OPENCL.


Found by Claude Opus 5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions