Linalg support for matrix determinant and inverse

I wonder whether tvm supports the following operators:

  1. matrix determinant (linalg_det).

  2. matrix inversion (linalg_inverse).

I searched the topi and relay library but failed to find these operators, and also failed to come up with an op-level equivalent transformation solution based on the current op inventory.

PS. In my research field, I need to build customized computaion graphs which include linalg_det and linalg_inverse, and I need to deploy the model in portable devices for online computation.

1 Like

For now, we can support linalg via TVM external functions: https://tvm.apache.org/docs/tutorials/language/extern_op.html#sphx-glr-tutorials-language-extern-op-py.

Thanks for help! @junrushao. It seems that linalg_det and linalg_inverse both need PLU decomposition, which is supported by:

  1. ./lapack-3.9.0/LAPACKE/src/lapacke_dgetrf.c
  2. ./lapack-3.9.0/LAPACKE/include/lapacke.h(seems not found in tvm external contribs).

Maybe new external runtime lib embedding and New op inventory can solve. Tons of work to do now, I have a direction though.

In this case, you may link the code into tvm_runtime, expose them with TVM_REGISTER_GLOBAL (i.e. as a packed function), then they can be used as tvm.extern. Example: https://github.com/apache/incubator-tvm/blob/master/src/runtime/contrib/nnpack/fully_connected.cc#L36