dwavesystems / dwave-optimization

Enables the formulation of nonlinear models for industrial optimization problems.
https://docs.ocean.dwavesys.com/en/stable/docs_optimization/index.html#index-optimization
Apache License 2.0
7 stars 18 forks source link

Consider adding matmul symbol or similar #145

Open jwoo098 opened 1 month ago

jwoo098 commented 1 month ago

A symbol that would return the matrix product of two arrays (similar to numpy.matmul)

jlalbers commented 2 weeks ago

Also brings up the question of how to handle a transpose, as these operations are frequently paired. Seems a bit heavy-handed to create a new node just to handle it, but it could also be a huge pain to implement within the node itself and might not be consistent with the design philosophy of other parts of the model.

arcondello commented 2 weeks ago

It would be a new node, similar to the existing ReshapeNode. The good news is that by messing around with strides etc, we can avoid having to hold the array at all! We would need to do some transposition of the updates that are propagated. But overall the node would be pretty light weight.

It also wouldn't support dynamic arrays, because arrays can only be dynamic in the 0th axis.

Added an issue https://github.com/dwavesystems/dwave-optimization/issues/160