apple / coremltools

Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
https://coremltools.readme.io
BSD 3-Clause "New" or "Revised" License
4.25k stars 613 forks source link

Implementation of basic linear algebra routines #1543

Open GLivshits opened 2 years ago

GLivshits commented 2 years ago

Hello. While trying to invert a model via your framework I've faced an absence of inverse matrix computation support (torch.inverse). I've tried to implement it by myself (via looking your code and creating my own operator via numpy), but it fails right after custom conversion: "ValueError: Cannot add const = matrixinv(x=%test, name="x")" at matmul operation which involved inverted matrix. Since there was another issue (with use of SVD) I think it would be great if raw torch and tensorflow routines would be added or a coincise method to register a custom op would be provided.

TobyRoseman commented 2 years ago

We're already tracking support for PyTorch inverse in #958. Are there other PyTorch linear algebra routines you would like to see supported?

You also mentioned TensorFlow. What linear algebra methods would you like supported there?

GLivshits commented 2 years ago

I also need SVD. My particular choice is PyTorch, but I've mentioned Tensorflow just to keep some sort of "unity" with other DL frameworks :)

TobyRoseman commented 2 years ago

Ok, so you would also like support for torch.svd, is that correct?

heathcliffYang commented 10 months ago

@TobyRoseman Would coremltools put torch.linalg.svd in implementation schedule? (torch.svd is deprecated by PyTorch)