Skip to content

Commit e44e919

Browse files
committed
Qualcomm AI Engine Direct - Streaming Mimi Enablement
1 parent df75088 commit e44e919

File tree

14 files changed

+2135
-211
lines changed

14 files changed

+2135
-211
lines changed

backends/qualcomm/_passes/lift_constant_scalar_operands.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ class TensorOpInfo:
4040
aten.ne.Scalar: TensorOpInfo(aten.ne.Tensor, False, False),
4141
aten.add.Scalar: TensorOpInfo(aten.add.Tensor, False, False),
4242
aten.add_.Scalar: TensorOpInfo(aten.add_.Tensor, False, False),
43+
# For below cases, refer to LiftAddTensor Model in UT for sample
44+
aten.add.Tensor: TensorOpInfo(aten.add.Tensor, False, False),
4345
aten.div.Scalar: TensorOpInfo(aten.div.Tensor, False, False),
4446
aten.mul.Scalar: TensorOpInfo(aten.mul.Tensor, False, False),
4547
aten.rsub.Scalar: TensorOpInfo(aten.rsub.Tensor, False, False),
4648
aten.sub.Scalar: TensorOpInfo(aten.sub.Tensor, False, False),
49+
aten.sub.Tensor: TensorOpInfo(aten.sub.Tensor, False, False),
4750
aten.pow.Tensor_Scalar: TensorOpInfo(aten.pow.Tensor_Tensor, False, False),
4851
# The scalar number arg[1] is missing when using default. Result in a corner case to deal
4952
aten.leaky_relu.default: TensorOpInfo(aten.prelu.default, True, False),

backends/qualcomm/_passes/remove_redundancy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def __init__(self):
2222
exir_ops.edge.aten.clone.default: self._default_condition,
2323
torch.ops.aten.alias.default: self._default_condition,
2424
exir_ops.edge.aten.alias.default: self._default_condition,
25+
exir_ops.edge.aten.alias_copy.default: self._default_condition,
2526
exir_ops.edge.aten.lift_fresh_copy.default: self._default_condition,
2627
# remove this target if '_skip_dim_order' is set to False
2728
exir_ops.edge.dim_order_ops._to_dim_order_copy.default: self._dim_order_op_condition,

backends/qualcomm/tests/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,15 @@ def forward(self, x):
939939
return self.constant < x
940940

941941

942+
class LiftAddTensor(torch.nn.Module):
943+
def __init__(self):
944+
super().__init__()
945+
946+
def forward(self, x):
947+
N = 2 - 1
948+
return x + N
949+
950+
942951
class Linear(torch.nn.Module):
943952
def __init__(self, use_bias: bool = True):
944953
super().__init__()

backends/qualcomm/tests/test_qnn_delegate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,12 @@ def test_qnn_backend_einsum_outer_product_relu(self):
980980
)
981981
self.lower_module_and_test_output(module, sample_input)
982982

983+
# TODO: Create a new UT class for passes specific checks
984+
def test_qnn_backend_lift_add_tensor(self):
985+
module = LiftAddTensor() # noqa: F405
986+
sample_input = (torch.Tensor([1, 2, 3, 4]).to(torch.int32),)
987+
self.lower_module_and_test_output(module, sample_input)
988+
983989
@unittest.skip("Fail because of bad accuracy")
984990
def test_qnn_backend_moe_feed_forward(self):
985991
args = ModelArgs()

examples/qualcomm/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/executor_runner)
9090
# build qnn_llama_runner for llama
9191
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/oss_scripts/llama)
9292

93+
# build qnn_mimi_decoder_runner
94+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/oss_scripts/moshi)
95+
9396
# build qaihub_llama2_7b_runner and qaihub_llama3_8b_runner
9497
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/qaihub_scripts/llama)
9598

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) Qualcomm Innovation Center, Inc.
2+
# All rights reserved
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set(_qnn_mimi_decoder_runner__srcs
8+
${CMAKE_CURRENT_LIST_DIR}/qnn_mimi_decoder_runner.cpp
9+
${CMAKE_CURRENT_LIST_DIR}/runner/runner.cpp
10+
${CMAKE_CURRENT_LIST_DIR}/runner/runner.h
11+
)
12+
13+
# build mimi decoder runner
14+
add_executable(qnn_mimi_decoder_runner ${_qnn_mimi_decoder_runner__srcs})
15+
target_include_directories(
16+
qnn_mimi_decoder_runner PUBLIC ${_common_include_directories}
17+
)
18+
target_link_libraries(
19+
qnn_mimi_decoder_runner
20+
qnn_executorch_backend
21+
executorch_core
22+
extension_module
23+
extension_data_loader
24+
gflags
25+
)
26+
27+
target_compile_options(
28+
qnn_llama_runner PUBLIC ${_common_compile_options}
29+
)
30+
31+
set_target_properties(
32+
qnn_mimi_decoder_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'"
33+
)

0 commit comments

Comments
 (0)