You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2023/01/18 22:59:06 UTC

[GitHub] [tvm] alanmacd opened a new pull request, #13807: Fix host-driven AOT memory workspaces

alanmacd opened a new pull request, #13807:
URL: https://github.com/apache/tvm/pull/13807

   When using host-driven AOT with memory pools enabled, the workspace and constant memory were not properly supported. In order for them to work properly, the _run function (typically tvmgen_default_run()) needed to be called instead of tvmgen_default___tvm_main__() in order to properly setup the memory workspace pointers.
   
   fixes #13777
   


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ashutosh-arm commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by GitBox <gi...@apache.org>.
ashutosh-arm commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1082873726


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   Hi @alanmacd, LGTM overall. I am not sure about whether this check can be removed. @d-smirnov knows more about it, so I will leave it to him.



##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   Hi @alanmacd, LGTM overall! I am not sure about whether this check can be removed. @d-smirnov knows more about it, so I will leave it to him.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1084757246


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   Additionally, added @mehrdadh's test_model_with_usmp() test to further test USMP. 



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] d-smirnov commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "d-smirnov (via GitHub)" <gi...@apache.org>.
d-smirnov commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1088269142


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,

Review Comment:
   Thanks a lot @alanmacd.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] mehrdadh merged pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "mehrdadh (via GitHub)" <gi...@apache.org>.
mehrdadh merged PR #13807:
URL: https://github.com/apache/tvm/pull/13807


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tvm-bot commented on pull request #13807: Fix host-driven AOT memory workspaces

Posted by GitBox <gi...@apache.org>.
tvm-bot commented on PR #13807:
URL: https://github.com/apache/tvm/pull/13807#issuecomment-1396204943

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   <!--bot-comment-ccs-start-->
    * No users to auto-tag found, no teams are specified in PR title <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] d-smirnov commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "d-smirnov (via GitHub)" <gi...@apache.org>.
d-smirnov commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1087217219


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   @alanmacd Thank you, Alan. I might be missing something but could you point out where the constant pools are initialised and passed to the main executor function? (It could be that the test might be giving false negative result)



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] leandron commented on pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by GitBox <gi...@apache.org>.
leandron commented on PR #13807:
URL: https://github.com/apache/tvm/pull/13807#issuecomment-1398000903

   Cc @ashutosh-arm @d-smirnov 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1082945629


##########
tests/python/unittest/test_micro_model_library_format.py:
##########
@@ -618,7 +618,6 @@ def test_multiple_relay_modules_aot_graph():
 
     assert os.path.exists(os.path.join(extract_dir, "codegen", "host", "src", "mod1_lib0.c"))
     assert os.path.exists(os.path.join(extract_dir, "codegen", "host", "src", "mod1_lib1.c"))
-    assert os.path.exists(os.path.join(extract_dir, "codegen", "host", "src", "mod1_lib2.c"))

Review Comment:
   The get_c_metadata() function was being added to the graph executor generated source files but never used.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] mehrdadh commented on pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "mehrdadh (via GitHub)" <gi...@apache.org>.
mehrdadh commented on PR #13807:
URL: https://github.com/apache/tvm/pull/13807#issuecomment-1398760068

   Overall LGTM! I'll wait for @d-smirnov before merging it. Thanks @alanmacd!!


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] mehrdadh commented on pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "mehrdadh (via GitHub)" <gi...@apache.org>.
mehrdadh commented on PR #13807:
URL: https://github.com/apache/tvm/pull/13807#issuecomment-1405658015

   @alanmacd @d-smirnov thanks! this PR is merged.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1087328934


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   @d-smirnov running `pytest tests/python/unittest/test_crt.py -k test_aot_executor_usmp_const_pool` and keeping the temporary files around, the generated C code will contain the following lines in   `tests/python/unittest/micro-workspace-usmp/project/model/codegen/host/src/default_lib0.c`, is that what you are asking about? Otherwise, I'm not quite sure I understand the question, could you give more context as to what you think may be missing?
   
   ```
   __attribute__((section(".rodata.tvm"), ))
   static struct global_const_workspace {
     uint8_t fused_add_constant_let[2] __attribute__((aligned(16))); // 2 bytes, aligned offset: 0
   } global_const_workspace = {
     .fused_add_constant_let = {
       0x08, 0x09
     },
   };// of total size 2 bytes
   TVM_DLL int32_t tvmgen_default___tvm_main__(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle);
   
   int32_t tvmgen_default_run(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle) {
   TVMValue tensors[4];
   tensors[0] = ((TVMValue*)args)[0];
   tensors[1] = ((TVMValue*)args)[1];
   tensors[2] = ((TVMValue*)args)[2];
   DLTensor global_const_workspace_dltensor = {
   .data = &global_const_workspace
   };
   TVMValue global_const_workspace_tvm_value = {
   .v_handle = &global_const_workspace_dltensor
   };
   tensors[3] = global_const_workspace_tvm_value;
   return tvmgen_default___tvm_main__((void*)tensors, type_code, num_args, out_value, out_type_code, resource_handle);
   }
   ```



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1084757246


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   Additionally, added @mehrdadh's test_model_with_usmp() test to further test USMP. 



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] mehrdadh commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "mehrdadh (via GitHub)" <gi...@apache.org>.
mehrdadh commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1082904042


##########
tests/python/unittest/test_micro_model_library_format.py:
##########
@@ -618,7 +618,6 @@ def test_multiple_relay_modules_aot_graph():
 
     assert os.path.exists(os.path.join(extract_dir, "codegen", "host", "src", "mod1_lib0.c"))
     assert os.path.exists(os.path.join(extract_dir, "codegen", "host", "src", "mod1_lib1.c"))
-    assert os.path.exists(os.path.join(extract_dir, "codegen", "host", "src", "mod1_lib2.c"))

Review Comment:
   Could you please comment why `mod2` is not generated anymore?



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] d-smirnov commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "d-smirnov (via GitHub)" <gi...@apache.org>.
d-smirnov commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1088112858


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   Thanks for clarifications @alanmacd 



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] d-smirnov commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "d-smirnov (via GitHub)" <gi...@apache.org>.
d-smirnov commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1088113155


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,

Review Comment:
   @alanmacd Should this be restored? (Along with TVMNDArray_IncrementReference(array) which is missing)



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1087328934


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   @d-smirnov running `pytest tests/python/unittest/test_crt.py -k test_aot_executor_usmp_const_pool` and keeping the temporary files around, the generated C code will contain the following lines in default_lib0.c, is that what you are asking about?
   ```
   __attribute__((section(".rodata.tvm"), ))
   static struct global_const_workspace {
     uint8_t fused_add_constant_let[2] __attribute__((aligned(16))); // 2 bytes, aligned offset: 0
   } global_const_workspace = {
     .fused_add_constant_let = {
       0x08, 0x09
     },
   };// of total size 2 bytes
   TVM_DLL int32_t tvmgen_default___tvm_main__(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle);
   
   int32_t tvmgen_default_run(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle) {
   TVMValue tensors[4];
   tensors[0] = ((TVMValue*)args)[0];
   tensors[1] = ((TVMValue*)args)[1];
   tensors[2] = ((TVMValue*)args)[2];
   DLTensor global_const_workspace_dltensor = {
   .data = &global_const_workspace
   };
   TVMValue global_const_workspace_tvm_value = {
   .v_handle = &global_const_workspace_dltensor
   };
   tensors[3] = global_const_workspace_tvm_value;
   return tvmgen_default___tvm_main__((void*)tensors, type_code, num_args, out_value, out_type_code, resource_handle);
   }
   ```



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1084659872


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   @d-smirnov I updated the` test_aot_executor_usmp_const_pool()` test to always enable USMP and now expect that to be successful



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1088240986


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,

Review Comment:
   @d-smirnov no, it doesn't make sense to allocate a workspace_pool, it will be in the generated C code similar to the const pool, there's an example below (I think I originally added the pool allocation and then you split it to workspace and const, but I don't think I should have added the pool allocation from the start)
   
   ```
   int32_t tvmgen_default_run(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle) {
   TVMValue tensors[4];
   tensors[0] = ((TVMValue*)args)[0];
   tensors[1] = ((TVMValue*)args)[1];
   DLTensor global_const_workspace_dltensor = {
   .data = &global_const_workspace
   };
   TVMValue global_const_workspace_tvm_value = {
   .v_handle = &global_const_workspace_dltensor
   };
   tensors[2] = global_const_workspace_tvm_value;
   DLTensor global_workspace_dltensor = {
   .data = &global_workspace
   };
   TVMValue global_workspace_tvm_value = {
   .v_handle = &global_workspace_dltensor
   };
   tensors[3] = global_workspace_tvm_value;
   return tvmgen_default___tvm_main__((void*)tensors, type_code, num_args, out_value, out_type_code, resource_handle);
   }
   ```



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1084659872


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   @d-smirnov I updated the `test_aot_executor_usmp_const_pool()` test to always enable USMP and now expect that to be successful



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] d-smirnov commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "d-smirnov (via GitHub)" <gi...@apache.org>.
d-smirnov commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1083049440


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   @alanmacd, Could you please add a unit test to replace the removed check for constant pools. 



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] alanmacd commented on a diff in pull request #13807: [microTVM] Fix host-driven AOT memory workspaces

Posted by "alanmacd (via GitHub)" <gi...@apache.org>.
alanmacd commented on code in PR #13807:
URL: https://github.com/apache/tvm/pull/13807#discussion_r1087328934


##########
src/runtime/crt/aot_executor/aot_executor.c:
##########
@@ -203,17 +203,6 @@ int TVMAotExecutor_Init(TVMAotExecutor* executor, TVMModuleHandle module_handle,
     TVMNDArray_IncrementReference(array);
   }
 
-  for (i = 0; i < md->num_workspace_pools; ++i) {
-    LOG_DEBUG("pools allocate[%d]: %s\n", i, md->workspace_pools[i].name);
-
-    status = TVMNDArray_Empty(md->workspace_pools[i].num_shape, md->workspace_pools[i].shape,
-                              md->workspace_pools[i].dtype, executor->device,
-                              &executor->args[arg_idx++]);
-    if (status != 0) {
-      return status;
-    }
-  }
-  CHECK_EQ(0, md->num_constant_pools, "Constant pools not supported");

Review Comment:
   @d-smirnov running `pytest tests/python/unittest/test_crt.py -k test_aot_executor_usmp_const_pool` and keeping the temporary files around, the generated C code will contain the following lines in   `tests/python/unittest/micro-workspace-usmp/project/model/codegen/host/src/default_lib0.c`, is that what you are asking about?
   ```
   __attribute__((section(".rodata.tvm"), ))
   static struct global_const_workspace {
     uint8_t fused_add_constant_let[2] __attribute__((aligned(16))); // 2 bytes, aligned offset: 0
   } global_const_workspace = {
     .fused_add_constant_let = {
       0x08, 0x09
     },
   };// of total size 2 bytes
   TVM_DLL int32_t tvmgen_default___tvm_main__(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle);
   
   int32_t tvmgen_default_run(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle) {
   TVMValue tensors[4];
   tensors[0] = ((TVMValue*)args)[0];
   tensors[1] = ((TVMValue*)args)[1];
   tensors[2] = ((TVMValue*)args)[2];
   DLTensor global_const_workspace_dltensor = {
   .data = &global_const_workspace
   };
   TVMValue global_const_workspace_tvm_value = {
   .v_handle = &global_const_workspace_dltensor
   };
   tensors[3] = global_const_workspace_tvm_value;
   return tvmgen_default___tvm_main__((void*)tensors, type_code, num_args, out_value, out_type_code, resource_handle);
   }
   ```



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org