diff options
Diffstat (limited to 'candle-metal-kernels/src/utils.rs')
-rw-r--r-- | candle-metal-kernels/src/utils.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/candle-metal-kernels/src/utils.rs b/candle-metal-kernels/src/utils.rs index 0092ecfa..025808d7 100644 --- a/candle-metal-kernels/src/utils.rs +++ b/candle-metal-kernels/src/utils.rs @@ -8,7 +8,7 @@ use std::ffi::c_void; pub(crate) fn linear_split(pipeline: &ComputePipelineState, length: usize) -> (MTLSize, MTLSize) { let size = length as u64; let width = std::cmp::min(pipeline.max_total_threads_per_threadgroup(), size); - let count = (size + width - 1) / width; + let count = size.div_ceil(width); let thread_group_count = MTLSize { width: count, height: 1, @@ -128,7 +128,7 @@ impl EncoderParam for (&Buffer, usize) { } } -impl<'a> EncoderParam for &BufferOffset<'a> { +impl EncoderParam for &BufferOffset<'_> { fn set_param(encoder: &ComputeCommandEncoderRef, position: u64, data: Self) { encoder.set_buffer(position, Some(data.buffer), data.offset_in_bytes as u64); } @@ -169,7 +169,7 @@ pub struct WrappedEncoder<'a> { end_encoding_on_drop: bool, } -impl<'a> Drop for WrappedEncoder<'a> { +impl Drop for WrappedEncoder<'_> { fn drop(&mut self) { if self.end_encoding_on_drop { self.inner.end_encoding() @@ -177,14 +177,15 @@ impl<'a> Drop for WrappedEncoder<'a> { } } -impl<'a> AsRef<metal::ComputeCommandEncoderRef> for WrappedEncoder<'a> { +impl AsRef<metal::ComputeCommandEncoderRef> for WrappedEncoder<'_> { fn as_ref(&self) -> &metal::ComputeCommandEncoderRef { self.inner } } impl EncoderProvider for &metal::CommandBuffer { - type Encoder<'a> = WrappedEncoder<'a> + type Encoder<'a> + = WrappedEncoder<'a> where Self: 'a; fn encoder(&self) -> Self::Encoder<'_> { @@ -196,7 +197,8 @@ impl EncoderProvider for &metal::CommandBuffer { } impl EncoderProvider for &metal::CommandBufferRef { - type Encoder<'a> = WrappedEncoder<'a> + type Encoder<'a> + = WrappedEncoder<'a> where Self: 'a; fn encoder(&self) -> Self::Encoder<'_> { @@ -208,7 +210,8 @@ impl EncoderProvider for &metal::CommandBufferRef { } impl EncoderProvider for &ComputeCommandEncoderRef { - type Encoder<'a> = WrappedEncoder<'a> + type Encoder<'a> + = WrappedEncoder<'a> where Self: 'a; fn encoder(&self) -> Self::Encoder<'_> { |