mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 11:56:45 +00:00
Owned command buffer now.
This commit is contained in:
@ -55,7 +55,8 @@ tracing-subscriber = "0.3.7"
|
|||||||
wav = "1.0.0"
|
wav = "1.0.0"
|
||||||
yoke = { version = "0.7.2", features = ["derive"] }
|
yoke = { version = "0.7.2", features = ["derive"] }
|
||||||
zip = { version = "0.6.6", default-features = false }
|
zip = { version = "0.6.6", default-features = false }
|
||||||
metal = { git = "https://github.com/ivarflakstad/metal-rs.git", features = ["mps"] }
|
# metal = { git = "https://github.com/ivarflakstad/metal-rs.git", features = ["mps"] }
|
||||||
|
metal = { path = "../metal-rs", features = ["mps"] }
|
||||||
|
|
||||||
[profile.release-with-debug]
|
[profile.release-with-debug]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
@ -21,7 +21,8 @@ pub enum MetalError {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MetalDevice {
|
pub struct MetalDevice {
|
||||||
device: metal::Device,
|
device: metal::Device,
|
||||||
command_queue: metal::CommandQueue,
|
_command_queue: metal::CommandQueue,
|
||||||
|
command_buffer: metal::CommandBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for MetalDevice {
|
impl std::fmt::Debug for MetalDevice {
|
||||||
@ -250,15 +251,13 @@ impl BackendStorage for MetalStorage {
|
|||||||
)
|
)
|
||||||
.expect("Failed to create matrix multiplication kernel");
|
.expect("Failed to create matrix multiplication kernel");
|
||||||
|
|
||||||
let buffer = self.device.command_queue.new_command_buffer();
|
|
||||||
// Encode kernel to command buffer
|
// Encode kernel to command buffer
|
||||||
matrix_multiplication.encode_to_command_buffer(
|
matrix_multiplication.encode_to_command_buffer(
|
||||||
&buffer,
|
&self.device.command_buffer,
|
||||||
&left_matrix,
|
&left_matrix,
|
||||||
&right_matrix,
|
&right_matrix,
|
||||||
&result_matrix,
|
&result_matrix,
|
||||||
);
|
);
|
||||||
buffer.commit();
|
|
||||||
Ok(Self{
|
Ok(Self{
|
||||||
buffer: out_buffer,
|
buffer: out_buffer,
|
||||||
device: self.device.clone(),
|
device: self.device.clone(),
|
||||||
@ -280,8 +279,9 @@ impl BackendDevice for MetalDevice {
|
|||||||
|
|
||||||
fn new(ordinal: usize) -> Result<Self> {
|
fn new(ordinal: usize) -> Result<Self> {
|
||||||
let device = metal::Device::all().swap_remove(ordinal);
|
let device = metal::Device::all().swap_remove(ordinal);
|
||||||
let command_queue = device.new_command_queue();
|
let _command_queue = device.new_command_queue();
|
||||||
Ok(Self { device, command_queue })
|
let command_buffer = _command_queue.new_owned_command_buffer();
|
||||||
|
Ok(Self { device, _command_queue, command_buffer })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_seed(&self, _seed: u64) -> Result<()> {
|
fn set_seed(&self, _seed: u64) -> Result<()> {
|
||||||
|
Reference in New Issue
Block a user