pub struct ClipTextConfig {
pub hidden_size: usize,
pub intermediate_size: usize,
pub num_attention_heads: usize,
pub num_hidden_layers: usize,
pub max_position_embeddings: usize,
pub vocab_size: usize,
pub layer_norm_eps: f64,
}Expand description
Configuration for the SD-1.5 CLIP text encoder
(runwayml/stable-diffusion-v1-5/text_encoder/config.json).
Fields§
Hidden width. SD-1.5: 768.
intermediate_size: usizeFFN expansion width. SD-1.5: 3072.
num_attention_heads: usizeNumber of attention heads per layer. SD-1.5: 12. Must divide
hidden_size evenly.
Number of transformer layers. SD-1.5: 12.
max_position_embeddings: usizeMaximum sequence length. SD-1.5: 77.
vocab_size: usizeToken vocabulary size. SD-1.5: 49408.
layer_norm_eps: f64LayerNorm epsilon. SD-1.5: 1e-5.
Implementations§
Source§impl ClipTextConfig
impl ClipTextConfig
Sourcepub fn validate(&self) -> FerrotorchResult<()>
pub fn validate(&self) -> FerrotorchResult<()>
Validate field bounds.
§Errors
Returns FerrotorchError::InvalidArgument for any out-of-bounds
or arithmetic-incompatible field.
Sourcepub fn from_json_str(s: &str) -> FerrotorchResult<Self>
pub fn from_json_str(s: &str) -> FerrotorchResult<Self>
Parse a text_encoder/config.json document into a ClipTextConfig.
Recognised keys (all optional — anything missing falls back to the
SD-1.5 defaults): hidden_size, intermediate_size,
num_attention_heads, num_hidden_layers,
max_position_embeddings, vocab_size, layer_norm_eps.
§Errors
Returns FerrotorchError::InvalidArgument on malformed JSON or
invalid field values.
Sourcepub fn from_file(path: &Path) -> FerrotorchResult<Self>
pub fn from_file(path: &Path) -> FerrotorchResult<Self>
Parse a text_encoder/config.json file from disk.
§Errors
Returns FerrotorchError::InvalidArgument for I/O or parse
failures.
Trait Implementations§
Source§impl Clone for ClipTextConfig
impl Clone for ClipTextConfig
Source§fn clone(&self) -> ClipTextConfig
fn clone(&self) -> ClipTextConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClipTextConfig
impl Debug for ClipTextConfig
Auto Trait Implementations§
impl Freeze for ClipTextConfig
impl RefUnwindSafe for ClipTextConfig
impl Send for ClipTextConfig
impl Sync for ClipTextConfig
impl Unpin for ClipTextConfig
impl UnsafeUnpin for ClipTextConfig
impl UnwindSafe for ClipTextConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more