pub struct CoreMlUnits { /* private fields */ }Expand description
The compute units of each Core ML function (embed_32 .. embed_512).
Self::per_length_default is what a Core ML bundle uses unless
EmbedderConfig::with_coreml_units says
otherwise. Each function is loaded once on its own unit and kept resident.
Implementations§
Source§impl CoreMlUnits
impl CoreMlUnits
Sourcepub fn per_length_default() -> Self
pub fn per_length_default() -> Self
The measured default (Mac matrix, RightKit issue #81): cpu_and_ne for graphs of up to
128 tokens (32, 64, 128; p50 about 2.3-3.0 ms) and cpu_and_gpu for 256 and 512
(p50 about 5.1 ms and 9.8-18.7 ms). The first cpu_and_gpu call per length can take
up to 51 s cold (shader build), which is why load pre-warms every function.
Sourcepub fn uniform(unit: CoreMlComputeUnit) -> Self
pub fn uniform(unit: CoreMlComputeUnit) -> Self
Every function on unit (forces all, cpu_and_ne, cpu_and_gpu or cpu_only).
Sourcepub fn with_length(self, length: usize, unit: CoreMlComputeUnit) -> Option<Self>
pub fn with_length(self, length: usize, unit: CoreMlComputeUnit) -> Option<Self>
This map with the function of length tokens moved to unit. None when length is
not one of 32, 64, 128, 256, 512.
Sourcepub fn unit_for(&self, length: usize) -> Option<CoreMlComputeUnit>
pub fn unit_for(&self, length: usize) -> Option<CoreMlComputeUnit>
The unit of the function of length tokens; None for a length that is not a graph.
Sourcepub fn entries(&self) -> impl Iterator<Item = (usize, CoreMlComputeUnit)> + '_
pub fn entries(&self) -> impl Iterator<Item = (usize, CoreMlComputeUnit)> + '_
(length, unit) for every function, shortest first.
Sourcepub fn is_cpu_only(&self) -> bool
pub fn is_cpu_only(&self) -> bool
True when every function runs on cpu_only.
Trait Implementations§
Source§impl Clone for CoreMlUnits
impl Clone for CoreMlUnits
Source§impl Debug for CoreMlUnits
impl Debug for CoreMlUnits
Source§impl Default for CoreMlUnits
impl Default for CoreMlUnits
Source§impl Display for CoreMlUnits
impl Display for CoreMlUnits
impl Eq for CoreMlUnits
Source§impl From<CoreMlComputeUnit> for CoreMlUnits
impl From<CoreMlComputeUnit> for CoreMlUnits
Source§fn from(unit: CoreMlComputeUnit) -> Self
fn from(unit: CoreMlComputeUnit) -> Self
Every function on unit, like CoreMlUnits::uniform.
Source§impl FromStr for CoreMlUnits
impl FromStr for CoreMlUnits
Source§fn from_str(text: &str) -> Result<Self, Self::Err>
fn from_str(text: &str) -> Result<Self, Self::Err>
A caller-facing override string (a setting or environment variable):
defaultorper_length:Self::per_length_default;- a bare unit (
all,cpu_and_ne,cpu_and_gpu,cpu_only): every function on it; length=unitpairs separated by commas (256=cpu_only,512=cpu_only): those lengths override the per-length default, the others keep it. A length may appear once.
Source§type Err = CoreMlUnitsParseError
type Err = CoreMlUnitsParseError
Source§impl PartialEq for CoreMlUnits
impl PartialEq for CoreMlUnits
impl StructuralPartialEq for CoreMlUnits
Auto Trait Implementations§
impl Freeze for CoreMlUnits
impl RefUnwindSafe for CoreMlUnits
impl Send for CoreMlUnits
impl Sync for CoreMlUnits
impl Unpin for CoreMlUnits
impl UnsafeUnpin for CoreMlUnits
impl UnwindSafe for CoreMlUnits
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more