summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaurent <laurent.mazare@gmail.com>2023-06-28 22:02:23 +0100
committerlaurent <laurent.mazare@gmail.com>2023-06-28 22:02:23 +0100
commiteaa3ce359e8d378e08ea147bd0291a75b4ec76d0 (patch)
treee03f935206c4c5b87cb743ca25b53ccd2c51879b
parent1328b5cb206dce9135c3d73dd6a5bd08f5e16d6a (diff)
downloadcandle-eaa3ce359e8d378e08ea147bd0291a75b4ec76d0.tar.gz
candle-eaa3ce359e8d378e08ea147bd0291a75b4ec76d0.tar.bz2
candle-eaa3ce359e8d378e08ea147bd0291a75b4ec76d0.zip
Cosmetic change.
-rw-r--r--candle-core/src/cpu_backend.rs50
1 files changed, 10 insertions, 40 deletions
diff --git a/candle-core/src/cpu_backend.rs b/candle-core/src/cpu_backend.rs
index 136eeaba..a47d7c18 100644
--- a/candle-core/src/cpu_backend.rs
+++ b/candle-core/src/cpu_backend.rs
@@ -604,52 +604,22 @@ impl CpuStorage {
pub(crate) fn ones_impl(shape: &Shape, dtype: DType) -> Self {
let elem_count = shape.elem_count();
match dtype {
- DType::U32 => {
- let data = vec![1u32; elem_count];
- Self::U32(data)
- }
- DType::BF16 => {
- let data = vec![bf16::ONE; elem_count];
- Self::BF16(data)
- }
- DType::F16 => {
- let data = vec![f16::ONE; elem_count];
- Self::F16(data)
- }
- DType::F32 => {
- let data = vec![1f32; elem_count];
- Self::F32(data)
- }
- DType::F64 => {
- let data = vec![1f64; elem_count];
- Self::F64(data)
- }
+ DType::U32 => Self::U32(vec![1u32; elem_count]),
+ DType::BF16 => Self::BF16(vec![bf16::ONE; elem_count]),
+ DType::F16 => Self::F16(vec![f16::ONE; elem_count]),
+ DType::F32 => Self::F32(vec![1f32; elem_count]),
+ DType::F64 => Self::F64(vec![1f64; elem_count]),
}
}
pub(crate) fn zeros_impl(shape: &Shape, dtype: DType) -> Self {
let elem_count = shape.elem_count();
match dtype {
- DType::U32 => {
- let data = vec![0u32; elem_count];
- Self::U32(data)
- }
- DType::BF16 => {
- let data = vec![bf16::ZERO; elem_count];
- Self::BF16(data)
- }
- DType::F16 => {
- let data = vec![f16::ZERO; elem_count];
- Self::F16(data)
- }
- DType::F32 => {
- let data = vec![0f32; elem_count];
- Self::F32(data)
- }
- DType::F64 => {
- let data = vec![0f64; elem_count];
- Self::F64(data)
- }
+ DType::U32 => Self::U32(vec![0u32; elem_count]),
+ DType::BF16 => Self::BF16(vec![bf16::ZERO; elem_count]),
+ DType::F16 => Self::F16(vec![f16::ZERO; elem_count]),
+ DType::F32 => Self::F32(vec![0f32; elem_count]),
+ DType::F64 => Self::F64(vec![0f64; elem_count]),
}
}
}