Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backends/qualcomm/_passes/layout_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class LayoutTransform(ExportPass):
exir_ops.edge.aten.le.Tensor,
exir_ops.edge.aten.linear.default,
exir_ops.edge.aten.log.default,
exir_ops.edge.aten.logical_and.default,
exir_ops.edge.aten.logical_not.default,
exir_ops.edge.aten.lt.Scalar,
exir_ops.edge.aten.lt.Tensor,
Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/builders/op_and.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@register_node_visitor
class OpAnd(NodeVisitor):
target = ["aten.bitwise_and.Tensor"]
target = ["aten.bitwise_and.Tensor", "aten.logical_and.default"]

def __init__(self, *args) -> None:
super().__init__(*args)
Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/quantizer/annotators.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def annotate_sigmoid(node: Node, quantization_config: QuantizationConfig) -> Non
)


@register_annotator([torch.ops.aten.__and__.Tensor])
@register_annotator([torch.ops.aten.__and__.Tensor, torch.ops.aten.logical_and.default])
def annotate_and(node: Node, quantization_config: QuantizationConfig) -> None:
annotate_binary(node, quantization_config)

Expand Down
8 changes: 8 additions & 0 deletions backends/qualcomm/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,14 @@ def forward(self, x):
return torch.log(x)


class LogicalAnd(torch.nn.Module):
def __init__(self):
super().__init__()

def forward(self, x, y):
return torch.logical_and(x != 0, y != 0).float()


class LogicalNot(torch.nn.Module):
def __init__(self):
super().__init__()
Expand Down
15 changes: 15 additions & 0 deletions backends/qualcomm/tests/test_qnn_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,13 @@ def test_qnn_backend_log(self):
sample_input = (torch.rand([1, 2, 3, 4]),)
self.lower_module_and_test_output(module, sample_input)

def test_qnn_backend_logical_and(self):
module = LogicalAnd() # noqa: F405
input1 = torch.tensor([True, False, True, False])
input2 = torch.tensor([True, True, False, False])
sample_input = (input1, input2)
self.lower_module_and_test_output(module, sample_input)

def test_qnn_backend_logical_not(self):
module = LogicalNot() # noqa: F405
sample_input = (torch.rand([1, 2, 3, 4]),)
Expand Down Expand Up @@ -2484,6 +2491,14 @@ def test_qnn_backend_log(self):
module = self.get_qdq_module(module, sample_input)
self.lower_module_and_test_output(module, sample_input)

def test_qnn_backend_logical_and(self):
module = LogicalAnd() # noqa: F405
input1 = torch.tensor([0.0])
input2 = torch.tensor([1.0])
sample_input = (input1, input2)
module = self.get_qdq_module(module, sample_input)
self.lower_module_and_test_output(module, sample_input)

def test_qnn_backend_logical_not(self):
module = LogicalNot() # noqa: F405
sample_input = (torch.rand([1, 2, 3, 4]),)
Expand Down
Loading