mirror of
https://github.com/huggingface/candle.git
synced 2025-06-15 18:28:24 +00:00
Added LeakyRelu implementation
This commit is contained in:
@ -1051,6 +1051,19 @@ pub fn simple_eval(
|
||||
}.to_dtype(DType::I64)?;
|
||||
values.insert(node.output[0].clone(), output);
|
||||
}
|
||||
"LeakyRelu" => {
|
||||
let input = get(&node.input[0])?;
|
||||
let dt = input.dtype();
|
||||
match dt {
|
||||
DType::U8 | DType::U32 | DType::I64 => {
|
||||
bail!("unsupported dtype {}, only float types are allowed for LeakyRelu", dt.as_str())
|
||||
}
|
||||
DType::BF16 | DType::F16 | DType::F32 | DType::F64 => {}
|
||||
}
|
||||
let alpha = get_attr_opt::<f32>(node, "alpha")?.copied().unwrap_or(0.01);
|
||||
let output = candle_nn::ops::leaky_relu(input, alpha.into())?;
|
||||
values.insert(node.output[0].clone(), output);
|
||||
}
|
||||
op_type => bail!("unsupported op_type {op_type} for op {node:?}"),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user