Struct furiosa_device::DeviceConfig
source · pub struct DeviceConfig { /* private fields */ }
Expand description
Describes a required set of devices for find_device_files
.
Examples
use furiosa_device::DeviceConfig;
// 1 core
DeviceConfig::warboy().build();
// 1 core x 2
DeviceConfig::warboy().count(2);
// Fused 2 cores x 2
DeviceConfig::warboy().fused().count(2);
Textual Representation
DeviceConfig supports textual representation, which is its equivalent string representation.
One can obtain the corresponding DeviceConfig from the textual representation
by using the FromStr trait, or by calling from_env
after setting an environment variable.
use std::str::FromStr;
use furiosa_device::DeviceConfig;
let config = DeviceConfig::from_env("SOME_OTHER_ENV_KEY").build();
let config = DeviceConfig::from_str("npu:0:0,npu:0:1").unwrap(); // get config directly from a string literal
The rules for textual representation are as follows:
use std::str::FromStr;
use furiosa_device::DeviceConfig;
// Using specific device names
DeviceConfig::from_str("npu:0:0").unwrap(); // npu0pe0
DeviceConfig::from_str("npu:0:0-1").unwrap(); // npu0pe0-1
// Using device configs
DeviceConfig::from_str("warboy*2").unwrap(); // single pe x 2 (equivalent to "warboy(1)*2")
DeviceConfig::from_str("warboy(1)*2").unwrap(); // single pe x 2
DeviceConfig::from_str("warboy(2)*2").unwrap(); // 2-pe fusioned x 2
// Combine multiple representations separated by commas
DeviceConfig::from_str("npu:0:0-1,npu:1:0-1").unwrap(); // npu0pe0-1, npu1pe0-1
Implementations§
source§impl DeviceConfig
impl DeviceConfig
sourcepub fn warboy() -> DeviceConfigBuilder<Arch, NotDetermined, NotDetermined>
pub fn warboy() -> DeviceConfigBuilder<Arch, NotDetermined, NotDetermined>
Returns a builder associated with Warboy NPUs.
pub fn warboy_a0() -> DeviceConfigBuilder<Arch, NotDetermined, NotDetermined>
sourcepub fn from_env<K: ToString>(key: K) -> EnvBuilder<NotDetermined>
pub fn from_env<K: ToString>(key: K) -> EnvBuilder<NotDetermined>
Returns a builder struct to read config saved in an environment variable. You can provide fallback options to the builder in case the envrionment variable is empty.
Trait Implementations§
source§impl Clone for DeviceConfig
impl Clone for DeviceConfig
source§fn clone(&self) -> DeviceConfig
fn clone(&self) -> DeviceConfig
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DeviceConfig
impl Debug for DeviceConfig
source§impl Default for DeviceConfig
impl Default for DeviceConfig
source§impl<'de> Deserialize<'de> for DeviceConfig
impl<'de> Deserialize<'de> for DeviceConfig
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for DeviceConfig
impl Display for DeviceConfig
source§impl From<DeviceConfig> for String
impl From<DeviceConfig> for String
source§fn from(config: DeviceConfig) -> Self
fn from(config: DeviceConfig) -> Self
Converts to this type from the input type.
source§impl FromStr for DeviceConfig
impl FromStr for DeviceConfig
source§impl Serialize for DeviceConfig
impl Serialize for DeviceConfig
source§impl<'a> TryFrom<&'a str> for DeviceConfig
impl<'a> TryFrom<&'a str> for DeviceConfig
source§impl TryInto<DeviceConfig> for NotDetermined
impl TryInto<DeviceConfig> for NotDetermined
§type Error = DeviceError
type Error = DeviceError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl RefUnwindSafe for DeviceConfig
impl Send for DeviceConfig
impl Sync for DeviceConfig
impl Unpin for DeviceConfig
impl UnwindSafe for DeviceConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more