Skip to content

Commit

Permalink
Fix a bug in the metal implemtation of col2im1d. (huggingface#2284)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare authored and EricLBuehler committed Jun 29, 2024
1 parent f7095bb commit b55b360
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion candle-core/src/metal_backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ impl BackendStorage for MetalStorage {
.device
.new_buffer(dst_el, self.dtype, "conv_transpose1d")?;

let command_buffer = self.device.command_buffer()?;
let name = match self.dtype {
DType::F32 => "col2im1d_f32",
DType::U32 => "col2im1d_u32",
Expand All @@ -869,6 +868,12 @@ impl BackendStorage for MetalStorage {
&kernel_l_mm,
)?
};
// It is important for the command buffer to be obtained *after* the matmul
// kernel has run, otherwise we might use a command-buffer that has been commited
// already resulting in the following error.
// _status < MTLCommandBufferStatusCommitted >
// -[IOGPUMetalCommandBuffer setCurrentCommandEncoder:]
let command_buffer = self.device.command_buffer()?;
candle_metal_kernels::call_col2im1d(
&self.device.device,
&command_buffer,
Expand Down

0 comments on commit b55b360

Please sign in to comment.