This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 11f0e422eb [BugFix][NNAPI] Fix type mismatch and test_mean annotation 
(#18140)
11f0e422eb is described below

commit 11f0e422ebb9cccac0b9f664b4517599e7f0c987
Author: Henry Hsieh <[email protected]>
AuthorDate: Mon Jul 14 19:57:13 2025 +0800

    [BugFix][NNAPI] Fix type mismatch and test_mean annotation (#18140)
    
    * [BugFix][NNAPI] Fix type mismatch in NNAPICompiler
    
    This commit explicitly casts the `tvm::ffi::Any`
    returned by `runtime.nnapi_runtime_create` to
    `tvm::runtime::Module` before adding it to the
    `Array<runtime::Module>` in response to the recent
    FFI refactor (commit 2d964b4) that phased out the
    legacy C API.
    
    Co-authored-by: HMZ <[email protected]>
    
    * [BugFix][NNAPI] Fix annotation in test_mean
    
    This commit corrects the StructInfo annotation of the
    tensor returned by `R.mean` from `(1, 10, 15)` to
    `(1, 10, 1)` to match the actual output shape.
    
    Co-authored-by: HMZ <[email protected]>
    
    ---------
    
    Co-authored-by: HMZ <[email protected]>
---
 src/relax/backend/contrib/nnapi/codegen.cc  | 4 +++-
 tests/python/nightly/test_nnapi/test_ops.py | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/relax/backend/contrib/nnapi/codegen.cc 
b/src/relax/backend/contrib/nnapi/codegen.cc
index a00ae0d010..f3b0e7bb95 100644
--- a/src/relax/backend/contrib/nnapi/codegen.cc
+++ b/src/relax/backend/contrib/nnapi/codegen.cc
@@ -259,7 +259,9 @@ Array<runtime::Module> NNAPICompiler(Array<Function> 
functions, Map<String, ffi:
     auto constant_names = serializer.GetConstantNames();
     const auto pf = 
tvm::ffi::Function::GetGlobalRequired("runtime.nnapi_runtime_create");
     auto func_name = GetExtSymbol(func);
-    compiled_functions.push_back(pf(func_name, graph_json, constant_names));
+    auto result = pf(func_name, graph_json, constant_names);
+    tvm::runtime::Module mod = result.cast<tvm::runtime::Module>();
+    compiled_functions.push_back(mod);
   }
 
   return compiled_functions;
diff --git a/tests/python/nightly/test_nnapi/test_ops.py 
b/tests/python/nightly/test_nnapi/test_ops.py
index 31d584db13..a6837d2ce5 100644
--- a/tests/python/nightly/test_nnapi/test_ops.py
+++ b/tests/python/nightly/test_nnapi/test_ops.py
@@ -272,7 +272,7 @@ def test_mean():
             ) -> R.Tensor((1, 10, 1), "float32"):
                 n = T.int64()
                 with R.dataflow():
-                    t0: R.Tensor((1, 10, 15), "float32") = R.mean(i0, 
axis=[-1], keepdims=True)
+                    t0: R.Tensor((1, 10, 1), "float32") = R.mean(i0, 
axis=[-1], keepdims=True)
                     R.output(t0)
                 return t0
 

Reply via email to