CPU mx.linalg.cholesky_inverse and mx.linalg.tri_inv (#1307)

* add cholesky inv + tri inv

* always run tri_inv on cpu

* consistent naming
This commit is contained in:
Alex Barron
2024-08-08 15:18:02 -07:00
committed by GitHub
parent 780c197f95
commit 32668a7317
7 changed files with 267 additions and 62 deletions

View File

@@ -2127,7 +2127,8 @@ class SVD : public Primitive {
/* Matrix inversion primitive. */
class Inverse : public UnaryPrimitive {
public:
explicit Inverse(Stream stream) : UnaryPrimitive(stream) {}
explicit Inverse(Stream stream, bool tri, bool upper)
: UnaryPrimitive(stream), tri_(tri), upper_(upper) {}
void eval_cpu(const std::vector<array>& inputs, array& output) override;
void eval_gpu(const std::vector<array>& inputs, array& output) override;
@@ -2137,6 +2138,8 @@ class Inverse : public UnaryPrimitive {
private:
void eval(const std::vector<array>& inputs, array& output);
bool tri_;
bool upper_;
};
class Cholesky : public UnaryPrimitive {