Skip to content

Commit

Permalink
feat: qr/2 for square matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Nov 9, 2023
1 parent b76b470 commit fd7b444
Show file tree
Hide file tree
Showing 7 changed files with 565 additions and 3 deletions.
14 changes: 13 additions & 1 deletion lib/candlex/backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,19 @@ defmodule Candlex.Backend do
|> Stream.map(&to_nx(&1, out))
end

# LinAlg

@impl true
def qr({out_q, out_r}, %T{shape: {n, n}} = tensor, _opts) do
{native_q, native_r} =
tensor
|> from_nx()
|> Native.qr()
|> unwrap!()

{to_nx(native_q, out_q), to_nx(native_r, out_r)}
end

for op <- [
:cholesky,
:conjugate,
Expand All @@ -876,7 +889,6 @@ defmodule Candlex.Backend do
:ifft,
:lu,
:product,
:qr,
:reverse,
:sort
] do
Expand Down
1 change: 1 addition & 0 deletions lib/candlex/native.ex
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ defmodule Candlex.Native do
:log,
:log1p,
:negate,
:qr,
:round,
:rsqrt,
:sigmoid,
Expand Down
Loading

0 comments on commit fd7b444

Please sign in to comment.