tkonolige commented on a change in pull request #7267:
URL: https://github.com/apache/tvm/pull/7267#discussion_r562824062
##########
File path: python/tvm/relay/frontend/tensorflow.py
##########
@@ -941,9 +934,48 @@ def _impl(inputs, attr, params, mod):
(values_tensor, (rows, cols)),
shape=tuple(dense_shape_tensor.tolist())
)
+ # As per tensorflow implementation, we have 4 possible input
combination
+ # and the first input(A) is always sparse and second input(B) is
always dense.
+ # Case 1: A , B , adjoint_a=False, adjoint_b=False --> A * B
+ # Case 2: A , B , adjoint_a=True, adjoint_b=False --> A.T * B
+ # Case 3: A , B , adjoint_a=False, adjoint_b=True --> A * B.T
+ # Case 4: A , B , adjoint_a=True, adjoint_b=True --> (A.T * B.T).T
+ #
+ # Topi implementation for sparse_dense(matmul) has 2 possible input
+ # combination where first input(A) is always dense
+ # and second input(B) is always sparse.
+ # Case 1: A , B, sparse_lhs = False --> A * B.T
+ # Case 2: A , B, sparse_lhs = True --> B * A.T
+ #
+ # The mapping would be as below:
+ # TF Case 1: A , B , adjoint_a=False, adjoint_b=False
Review comment:
Could you show the intermediate steps here. i.e. `A * B --> A * B.T.T
--> sparse_dense(B.T, A, sparse_lhs=True)`
##########
File path: python/tvm/relay/frontend/tensorflow.py
##########
@@ -942,7 +942,10 @@ def _impl(inputs, attr, params, mod):
)
if sparse_lhs:
- data = _op.transpose(data)
+ if attr.get("adjoint_a"):
Review comment:
Given the comment has 4 cases, I think it is most intuitive if the
if-cases follow the same structure.
```python
if adjoint_a and adjoint_b:
B = transpose(B)
sparse_lhs = True
elif adjoint_a and not adjoint_b:
...
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]