* add llamacpp plugin * Refactor llamacpp plugin * add utils plugin * remove utils folder * add hardware implementation * add utils folder + move utils function * organize cargo files * refactor utils src * refactor util * apply fmt * fmt * Update gguf + reformat * add permission for gguf commands * fix cargo test windows * revert yarn lock * remove cargo.lock for hardware plugin * ignore cargo.lock file * Fix hardware invoke + refactor hardware + refactor tests, constants * use api wrapper in extension to invoke hardware call + api wrapper build integration * add newline at EOF (per Akarshan) * add vi mock for getSystemInfo
34 lines
854 B
Rust
34 lines
854 B
Rust
use crate::{
|
|
constants::{VENDOR_ID_AMD, VENDOR_ID_INTEL, VENDOR_ID_NVIDIA},
|
|
types::{GpuInfo, GpuUsage, Vendor},
|
|
};
|
|
|
|
impl Vendor {
|
|
pub fn from_vendor_id(vendor_id: u32) -> Self {
|
|
match vendor_id {
|
|
VENDOR_ID_AMD => Vendor::AMD,
|
|
VENDOR_ID_NVIDIA => Vendor::NVIDIA,
|
|
VENDOR_ID_INTEL => Vendor::Intel,
|
|
_ => Vendor::Unknown(vendor_id),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl GpuInfo {
|
|
pub fn get_usage(&self) -> GpuUsage {
|
|
match self.vendor {
|
|
Vendor::NVIDIA => self.get_usage_nvidia(),
|
|
Vendor::AMD => self.get_usage_amd(),
|
|
_ => self.get_usage_unsupported(),
|
|
}
|
|
}
|
|
|
|
pub fn get_usage_unsupported(&self) -> GpuUsage {
|
|
GpuUsage {
|
|
uuid: self.uuid.clone(),
|
|
used_memory: 0,
|
|
total_memory: 0,
|
|
}
|
|
}
|
|
}
|