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

bug: index_select() does not work on CUDA if index array has zero elements #2673

Open
laptou opened this issue Dec 17, 2024 · 0 comments
Open

Comments

@laptou
Copy link
Contributor

laptou commented Dec 17, 2024

Here's a minimal reproduction:

use candle_core::{Device, Tensor};

pub fn main() -> candle_core::Result<()> {
    let device = Device::Cpu;
    let indices = Tensor::from_vec::<_, u32>(vec![], 0, &device)?;
    let sample = Tensor::randn(0., 1., (3, 3, 3), &device)?;

    // works fine, produces a result with shape (0, 3, 3)
    let result = sample.index_select(&indices, 0)?;
    dbg!(result);

    let device = Device::new_cuda(0)?;
    let indices = Tensor::from_vec::<_, u32>(vec![], 0, &device)?;
    let sample = Tensor::randn(0., 1., (3, 3, 3), &device)?;

    // crashes with Cuda(Cuda(DriverError(CUDA_ERROR_INVALID_VALUE, "invalid argument")))
    let result = sample.index_select(&indices, 0)?;
    dbg!(result);

    Ok(())
}

candle-core version is 0.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant