Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Nov 8, 2023
1 parent 67242c3 commit 90e0654
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions native/candlex/src/tensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,24 @@ pub fn qr(tensor: ExTensor) -> Result<(ExTensor, ExTensor), CandlexError> {
let side = tensor.dims()[0];
let device = tensor.device();

let qr =
nalgebra::linalg::QR::new(
nalgebra::DMatrix::from_vec(
side,
side,
tensor.t()?.flatten_all()?.to_vec1::<f32>()?
)
);

Ok(
(
ExTensor::new(
Tensor::new(qr.q().as_slice(), &device)?.reshape((side, side))?.t()?
),
ExTensor::new(
Tensor::new(qr.r().as_slice(), &device)?.reshape((side, side))?.t()?
)
)
)
let qr = nalgebra::linalg::QR::new(nalgebra::DMatrix::from_vec(
side,
side,
tensor.t()?.flatten_all()?.to_vec1::<f32>()?,
));

Ok((
ExTensor::new(
Tensor::new(qr.q().as_slice(), &device)?
.reshape((side, side))?
.t()?,
),
ExTensor::new(
Tensor::new(qr.r().as_slice(), &device)?
.reshape((side, side))?
.t()?,
),
))
}

#[rustler::nif(schedule = "DirtyCpu")]
Expand Down

0 comments on commit 90e0654

Please sign in to comment.