-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Arm tester] Run delegate nodes using tosa_reference_model
Instead of executing just one delegate, we execute the graph and dispatch the delegate nodes to the tosa_reference_model. This makes the tester more flexible and enables running tests with multiple delegates, multiple outputs etc. Signed-off-by: Erik Lundell <erik.lundell@arm.com> Change-Id: I5fb0192da2d187f29c025e0c51238a9cb7d7ec90
- Loading branch information
1 parent
08770b7
commit 781ad6d
Showing
9 changed files
with
286 additions
and
198 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2024-2025 Arm Limited and/or its affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import unittest | ||
|
||
import torch | ||
from executorch.backends.arm.test import common | ||
from executorch.backends.arm.test.tester.arm_tester import ArmTester | ||
|
||
|
||
class TestMultipleDelegates(unittest.TestCase): | ||
class MultipleDelegatesModule(torch.nn.Module): | ||
inputs = (torch.randn(10, 4, 5), torch.randn(10, 4, 5)) | ||
|
||
def get_inputs(self): | ||
return self.inputs | ||
|
||
def forward(self, x: torch.Tensor, y: torch.Tensor): | ||
z = x + y | ||
s = torch.sin(z) | ||
return s * z | ||
|
||
def test_tosa_MI(self): | ||
module = self.MultipleDelegatesModule() | ||
inputs = module.get_inputs() | ||
( | ||
ArmTester( | ||
module, | ||
example_inputs=inputs, | ||
compile_spec=common.get_tosa_compile_spec("TOSA-0.80+MI"), | ||
) | ||
.export() | ||
.to_edge_transform_and_lower() | ||
.check_count({"torch.ops.higher_order.executorch_call_delegate": 2}) | ||
.to_executorch() | ||
.run_method_and_compare_outputs(inputs=inputs) | ||
) | ||
|
||
def test_tosa_BI(self): | ||
module = self.MultipleDelegatesModule() | ||
inputs = module.get_inputs() | ||
( | ||
ArmTester( | ||
module, | ||
example_inputs=inputs, | ||
compile_spec=common.get_tosa_compile_spec("TOSA-0.80+BI"), | ||
) | ||
.quantize() | ||
.export() | ||
.to_edge_transform_and_lower() | ||
.check_count({"torch.ops.higher_order.executorch_call_delegate": 2}) | ||
.to_executorch() | ||
.run_method_and_compare_outputs(inputs=inputs, qtol=1.0) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2024-2025 Arm Limited and/or its affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import unittest | ||
|
||
import torch | ||
from executorch.backends.arm.test import common | ||
from executorch.backends.arm.test.tester.arm_tester import ArmTester | ||
|
||
|
||
class TestMultipleOutputs(unittest.TestCase): | ||
class MultipleOutputsModule(torch.nn.Module): | ||
inputs = (torch.randn(10, 4, 5), torch.randn(10, 4, 5)) | ||
|
||
def get_inputs(self): | ||
return self.inputs | ||
|
||
def forward(self, x: torch.Tensor, y: torch.Tensor): | ||
return (x * y, x.sum(dim=-1, keepdim=True)) | ||
|
||
def test_tosa_MI_pipeline(self): | ||
module = self.MultipleOutputsModule() | ||
inputs = module.get_inputs() | ||
( | ||
ArmTester( | ||
module, | ||
example_inputs=inputs, | ||
compile_spec=common.get_tosa_compile_spec("TOSA-0.80+MI"), | ||
) | ||
.export() | ||
.to_edge_transform_and_lower() | ||
.to_executorch() | ||
.run_method_and_compare_outputs(inputs=inputs) | ||
) | ||
|
||
def test_tosa_BI_pipeline(self): | ||
module = self.MultipleOutputsModule() | ||
inputs = module.get_inputs() | ||
( | ||
ArmTester( | ||
module, | ||
example_inputs=inputs, | ||
compile_spec=common.get_tosa_compile_spec("TOSA-0.80+BI"), | ||
) | ||
.quantize() | ||
.export() | ||
.to_edge_transform_and_lower() | ||
.to_executorch() | ||
.run_method_and_compare_outputs(inputs=inputs, qtol=1.0) | ||
) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.