Skip to content

Commit

Permalink
Handle empty tensors (must bind at minimum 4 bytes on wgpu) (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
laggui authored Aug 28, 2024
1 parent 2d38fe5 commit aebf106
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/cubecl-wgpu/src/compute/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,13 @@ where
.copied()
.chain(self.copy_handles_used.iter().map(|x| x.0))
.collect::<Vec<_>>();
let memory = self.memory_management.reserve(data.len(), &total_handles);
let num_bytes = data.len();

if let Some(len) = NonZero::new(data.len() as u64) {
// Handle empty tensors (must bind at minimum 4 bytes)
let reserve_size = core::cmp::max(num_bytes, 4);
let memory = self.memory_management.reserve(reserve_size, &total_handles);

if let Some(len) = NonZero::new(num_bytes as u64) {
let resource_handle = self.memory_management.get(memory.clone().binding());

// Dont re-use this handle for writing until the queue is flushed. All writes
Expand Down

0 comments on commit aebf106

Please sign in to comment.