tracel-ai / burn

Burn is a new comprehensive dynamic Deep Learning Framework built using Rust with extreme flexibility, compute efficiency and portability as its primary goals.

Home Page:https://burn.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bool nonzero panics when the entire tensor is false, on wgpu

McArthur-Alford opened this issue · comments

Describe the bug
the nonzero operator for boolean tensors, if given a tensor that is entirely false, panics. It isnt a particularly nice panic either.

The error:

thread 'main' panicked at /home/mcarthur/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:2996:5:
wgpu error: Validation Error

Caused by:
    In Device::create_bind_group
    Buffer binding size 0 is less than minimum 4
      note: buffer = `<Buffer-(11, 2, Vulkan)>`

This was produced by the following:

type B = Autodiff<Wgpu>;
let device = burn::backend::wgpu::WgpuDevice::BestAvailable;
let tensor: Tensor<B, 1, Bool> = Tensor::from_ints([0, 0, 0], &device).equal_elem(1);
tensor.nonzero();

Because of the error message, I tested it with NdArray and it worked fine, so I suspect its a WGPU issue.

Expected behavior
I would expect it to either panic with a more helpful error.... or give me an empty tensor

Desktop (please complete the following information):

  • Nixos, unstable
  • AMD gpu and intel CPU, in case it is relevant

I think this is simply a problem with the current memory management strategy that creates buffers that are too small. If you increase the size of the buffer, the test should pass. We are already working on a fix for the memory managment, should be out for the next release.