1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use tch::TchError;
use thiserror::Error;

/// Transformer errors.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum TransformerError {
    /// The hidden size is not a multiple of the number of attention heads.
    #[error("hidden size ({hidden_size:?}) is not a multiple of attention heads ({num_attention_heads:?})")]
    IncorrectHiddenSize {
        /// The hidden size.
        hidden_size: i64,

        /// The number of attention heads.
        num_attention_heads: i64,
    },

    /// Torch error.
    #[error(transparent)]
    Tch(#[from] TchError),

    /// The activation function is unknown.
    #[error("unknown activation function: {activation:?}")]
    UnknownActivationFunction { activation: String },
}