masahi commented on code in PR #14907:
URL: https://github.com/apache/tvm/pull/14907#discussion_r1201688800
##########
python/tvm/relax/frontend/torch/fx_translator.py:
##########
@@ -1015,19 +1015,24 @@ def _cross_entropy(self, node: fx.node.Node) ->
relax.Expr:
)
def _scaled_dot_product_attention(self, node: fx.node.Node) -> relax.Var:
- assert len(node.args) <= 4, "Dropout, and causal masking are not
supported."
+ assert (
+ len(node.args) <= 4
+ ), "Dropout is not supported, and is_causal should be called by
kwargs."
transpose_S_H = lambda tensor: relax.op.permute_dims(tensor, [0, 2, 1,
3])
query = transpose_S_H(self.env[node.args[0]])
key = transpose_S_H(self.env[node.args[1]])
value = transpose_S_H(self.env[node.args[2]])
+ causal_mask = (
+ "TopLeft" if "is_causal" in node.kwargs and
node.kwargs["is_causal"] is True else None
Review Comment:
I think we can use `node.kwargs.get("is_causal", False)` to simplify the
condition
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]