Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Apr 3, 2024
1 parent 4f17930 commit 2e748e8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
version = "0.1.0"

[workspace.dependencies]
reqwest = "0.12.1"
anyhow = "1.0.81"
async-trait = "0.1.78"
candle = { git = "https://github.com/huggingface/candle", package = "candle-core", version = "0.4.2" }
Expand All @@ -33,7 +34,6 @@ image = { version = "0.25.0", default-features = false, features = [
serde = "1.0.197"
serde_json = "1.0.114"
rand = "0.8.5"
reqwest = "0.12.1"
thiserror = "1.0.58"
tokenizers = "0.15.2"
tokio = "1.36.0"
Expand Down
5 changes: 1 addition & 4 deletions atoma-inference/src/candle/stable_diffusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ pub struct Input {

sd_version: StableDiffusionVersion,

/// Generate intermediary images at each step.
intermediary_images: bool,

use_flash_attn: bool,

use_f16: bool,
Expand Down Expand Up @@ -78,7 +75,6 @@ impl Input {
n_steps: Some(20),
num_samples: 1,
sd_version: StableDiffusionVersion::V1_5,
intermediary_images: false,
use_flash_attn: false,
use_f16: true,
guidance_scale: None,
Expand Down Expand Up @@ -315,6 +311,7 @@ impl CandleModel for StableDiffusion {
}
}

#[allow(dead_code)]
#[derive(Clone, Copy)]
enum StableDiffusionVersion {
V1_5,
Expand Down
8 changes: 2 additions & 6 deletions atoma-inference/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
pub mod model_thread;
pub mod apis;
pub mod candle;
pub mod config;
pub mod core_thread;
pub mod model_thread;
pub mod models;
pub mod service;
pub mod specs;

pub mod apis;
pub mod models;
6 changes: 2 additions & 4 deletions atoma-inference/src/models/candle/mamba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ impl ModelTrait for MambaModel {
let tokenizer_filename = filenames[1].clone();
let weights_filenames = filenames[2..].to_vec();

let tokenizer =
Tokenizer::from_file(tokenizer_filename).map_err(ModelError::TokenizerError)?;
let tokenizer = Tokenizer::from_file(tokenizer_filename)?;

let config: Config =
serde_json::from_slice(&std::fs::read(config_filename).map_err(ModelError::IoError)?)
Expand Down Expand Up @@ -110,8 +109,7 @@ impl ModelTrait for MambaModel {
let mut tokens = self
.tokenizer
.tokenizer()
.encode(prompt, true)
.map_err(ModelError::TokenizerError)?
.encode(prompt, true)?
.get_ids()
.to_vec();
let mut logits_processor =
Expand Down
26 changes: 13 additions & 13 deletions atoma-inference/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ pub trait Response: Send + 'static {

#[derive(Debug, Error)]
pub enum ModelError {
#[error("Tokenizer error: `{0}`")]
TokenizerError(Box<dyn std::error::Error + Send + Sync>),
#[error("IO error: `{0}`")]
IoError(std::io::Error),
#[error("Deserialize error: `{0}`")]
DeserializeError(serde_json::Error),
#[error("Candle error: `{0}`")]
CandleError(CandleError),
DeserializeError(#[from] serde_json::Error),
#[error("{0}")]
Msg(String),
}

impl From<CandleError> for ModelError {
fn from(error: CandleError) -> Self {
Self::CandleError(error)
}
#[error("Candle error: `{0}`")]
CandleError(#[from] CandleError),
#[error("Config error: `{0}`")]
Config(String),
#[error("Image error: `{0}`")]
ImageError(#[from] image::ImageError),
#[error("Io error: `{0}`")]
IoError(#[from] std::io::Error),
#[error("Error: `{0}`")]
BoxedError(#[from] Box<dyn std::error::Error + Send + Sync>),
#[error("ApiError error: `{0}`")]
ApiError(#[from] hf_hub::api::sync::ApiError),
}

#[macro_export]
Expand Down

0 comments on commit 2e748e8

Please sign in to comment.