Skip to content

Commit 58004bf

Browse files
committed
Fix all clippy warnings
1 parent 8a71b9c commit 58004bf

File tree

12 files changed

+22
-15
lines changed

12 files changed

+22
-15
lines changed

src/audio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum AudioFormat {
2323
}
2424

2525
impl AudioFormat {
26-
pub fn from_str(s: &str) -> Option<Self> {
26+
pub fn parse(s: &str) -> Option<Self> {
2727
match s.to_lowercase().as_str() {
2828
"wav" => Some(Self::Wav),
2929
"ogg" | "vorbis" => Some(Self::Ogg),
@@ -72,7 +72,7 @@ pub fn write_audio(
7272
.unwrap_or("wav")
7373
.to_lowercase();
7474

75-
match AudioFormat::from_str(&ext) {
75+
match AudioFormat::parse(&ext) {
7676
Some(AudioFormat::Wav) => write_wav(path, samples, sample_rate, num_channels),
7777
#[cfg(feature = "audio-ogg")]
7878
Some(AudioFormat::Ogg) => ogg::write_ogg(path, samples, sample_rate, num_channels),

src/audio/ogg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::Result;
44
use std::io::Write;
5-
use std::num::{NonZeroU8, NonZeroU32};
5+
use std::num::{NonZeroU32, NonZeroU8};
66

77
pub fn write_ogg_to<W: Write>(
88
writer: W,

src/audio/wav.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub fn write_wav(
5050
}
5151

5252
/// Peak-normalize audio samples to [-1, 1].
53+
#[allow(dead_code)]
5354
pub fn peak_normalize(samples: &mut [f32]) {
5455
let max_abs = samples.iter().map(|s| s.abs()).fold(0.0f32, f32::max);
5556
if max_abs > 1e-8 {
@@ -175,7 +176,7 @@ mod tests {
175176
let prev = vec![1.0f32; 16]; // 8 stereo frames
176177
let next = vec![0.0f32; 16];
177178
let result = crossfade(&prev, &next, 4, 2); // 4-frame crossfade
178-
// (16-8) + 8 + (16-8) = 24
179+
// (16-8) + 8 + (16-8) = 24
179180
assert_eq!(result.len(), 24);
180181
}
181182

src/bin/ace-step.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ fn main() -> anyhow::Result<()> {
9191
.and_then(|e| e.to_str())
9292
.unwrap_or("wav");
9393

94-
if ace_step_rs::audio::AudioFormat::from_str(ext).is_none() {
94+
if ace_step_rs::audio::AudioFormat::parse(ext).is_none() {
9595
anyhow::bail!("unsupported output format '{}'. Use .wav or .ogg", ext);
9696
}
9797

9898
// Ensure output directory exists
99-
if let Some(parent) = output_path.parent() {
100-
if !parent.as_os_str().is_empty() {
101-
std::fs::create_dir_all(parent)?;
102-
}
99+
if let Some(parent) = output_path.parent()
100+
&& !parent.as_os_str().is_empty()
101+
{
102+
std::fs::create_dir_all(parent)?;
103103
}
104104

105105
let device = candle_core::Device::cuda_if_available(0)?;

src/bin/generation-daemon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async fn process_request(line: &str, manager: &GenerationManager) -> Response {
257257
.extension()
258258
.and_then(|e| e.to_str())
259259
.unwrap_or("wav");
260-
if ace_step_rs::audio::AudioFormat::from_str(ext).is_none() {
260+
if ace_step_rs::audio::AudioFormat::parse(ext).is_none() {
261261
return Response::err(format!(
262262
"unsupported output format '{ext}'. Use .wav or .ogg"
263263
));

src/manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ fn maybe_proactive_offload(pipeline: AceStepPipeline, config: &ManagerConfig) ->
190190
///
191191
/// On success returns the CPU pipeline.
192192
/// On failure returns the original error and a recovered pipeline (reloaded on GPU).
193+
#[allow(clippy::result_large_err)]
193194
fn offload_to_cpu(
194195
pipeline: AceStepPipeline,
195196
config: &ManagerConfig,

src/model/encoder/timbre.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::model::transformer::mask::create_4d_mask;
1414

1515
/// Timbre encoder matching Python `AceStepTimbreEncoder`.
1616
#[derive(Debug, Clone)]
17+
#[allow(dead_code)]
1718
pub struct AceStepTimbreEncoder {
1819
embed_tokens: nn::Linear,
1920
norm: RmsNorm,
@@ -125,9 +126,9 @@ impl AceStepTimbreEncoder {
125126
}
126127

127128
// Build mask
128-
for bid in 0..b {
129+
for count in &counts {
129130
for pos in 0..max_count {
130-
mask_vals.push(if pos < counts[bid] { 1i64 } else { 0i64 });
131+
mask_vals.push(if pos < *count { 1i64 } else { 0i64 });
131132
}
132133
}
133134

src/model/generation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub struct GenerationOutput {
2323
pub struct AceStepConditionGenerationModel {
2424
decoder: AceStepDiTModel,
2525
encoder: AceStepConditionEncoder,
26+
#[allow(dead_code)]
2627
null_condition_emb: Tensor, // [1, 1, hidden_size]
2728
cfg: AceStepConfig,
2829
}
@@ -87,6 +88,7 @@ impl AceStepConditionGenerationModel {
8788
/// Generate audio latents from text/lyrics/timbre conditions.
8889
///
8990
/// Returns latents [B, T, 64] at 25Hz, ready for VAE decoding.
91+
#[allow(clippy::too_many_arguments)]
9092
pub fn generate_audio(
9193
&self,
9294
text_hidden_states: &Tensor,

src/model/tokenizer/fsq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use candle_core::{Result, Tensor};
1010
/// For inference we only need the forward pass (quantize) and
1111
/// `get_output_from_indices` (decode codes back to continuous).
1212
#[derive(Debug, Clone)]
13+
#[allow(dead_code)]
1314
pub struct ResidualFsq {
1415
/// Project from hidden_size to FSQ dim
1516
project_in: Option<candle_nn::Linear>,

src/model/transformer/attention.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub struct AceStepAttention {
128128
head_dim: usize,
129129
scaling: f64,
130130
is_cross_attention: bool,
131+
#[allow(dead_code)]
131132
sliding_window: Option<usize>,
132133
}
133134

0 commit comments

Comments
 (0)