tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

100% performance improvement MatMul

Open TheNewSound opened this issue 4 years ago • 2 comments

Describe the problem or feature request

When executing const result = tf.matMul(a,b,transposeA,transposeB); and the following holds: a==b && (transposeA ^ transposeB) (where ^ is the XOR-operator) Then tf.matMul only has to calculate the upper triangle and can mirror those values to the lower triangle of the resulting matrix or vice-versa.

const a = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3]);

a.matMul(a, true).print();
a.matMul(a, false, true).print(); 

I see the WebAssembly back-end currently does not take advantage of this property? Maybe this counts for other back-ends aswell? For example CUDA has cublas<t>syrk(), don't know if Tensorflow takes advantage of this in CUDA...

TheNewSound avatar May 25 '20 03:05 TheNewSound

Hi, @TheNewSound

Apologize for the delayed response and I tried to replicate the same issue from my end with wasm backend and I'm getting below output with latest version of @tensorflow/[email protected] so May I know have we taken care of this issue ?

image

Thank you for opening this issue. Since this issue has been open for a long time, the code/debug information for this issue may not be relevant with the current state of the code base.

The TFJs team is constantly improving the framework by fixing bugs and adding new features. We suggest you try the latest TFJs version with the latest compatible hardware configuration which could potentially resolve the issue. If you are still facing the issue, please create a new GitHub issue with your latest findings, with all the debugging information which could help us investigate.

Please follow the release notes to stay up to date with the latest developments which are happening in the Tensorflow.js space.

Thank you for your support and cooperation.

gaikwadrahul8 avatar Sep 01 '23 13:09 gaikwadrahul8

What I described was a performance optimization suggestion/question.

TheNewSound avatar Sep 07 '23 19:09 TheNewSound