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

jroesch 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 7072743  Remove old AOT Executor code (#8758)
7072743 is described below

commit 70727435a0827cd6cefe0b52f4407e08b799e39a
Author: Christopher Sidebottom <chris.sidebot...@arm.com>
AuthorDate: Wed Aug 18 22:57:37 2021 +0100

    Remove old AOT Executor code (#8758)
    
    * Remove old AOT Executor code
    
    This removes the old AOT execution functions that relied on the model 
descriptor which was removed in https://github.com/apache/tvm/pull/8280.
    
    * Remove rogue tvm_model_t from demo app
    
    * Remove aot_executor from demo CRT libs
---
 .../zephyr/template_project/microtvm_api_server.py |   2 +-
 .../zephyr/template_project/src/aot_demo/main.c    |   2 -
 cmake/modules/StandaloneCrt.cmake                  |   3 +-
 src/runtime/crt/Makefile                           |   1 -
 src/runtime/crt/aot_executor/aot_executor.c        |  62 -------
 .../crt/internal/aot_executor/aot_executor.h       |  83 ----------
 tests/crt/aot_executor_test.cc                     | 178 ---------------------
 tests/python/relay/aot/aot_test.mk                 |   6 +-
 8 files changed, 3 insertions(+), 334 deletions(-)

diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py 
b/apps/microtvm/zephyr/template_project/microtvm_api_server.py
index d937728..c51389a 100644
--- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py
+++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py
@@ -324,7 +324,7 @@ class Handler(server.ProjectAPIHandler):
 
     CRT_LIBS_BY_PROJECT_TYPE = {
         "host_driven": "microtvm_rpc_server microtvm_rpc_common common",
-        "aot_demo": "aot_executor memory microtvm_rpc_common common",
+        "aot_demo": "memory microtvm_rpc_common common",
     }
 
     def generate_project(self, model_library_format_path, standalone_crt_dir, 
project_dir, options):
diff --git a/apps/microtvm/zephyr/template_project/src/aot_demo/main.c 
b/apps/microtvm/zephyr/template_project/src/aot_demo/main.c
index 276c231..a96e3b4 100644
--- a/apps/microtvm/zephyr/template_project/src/aot_demo/main.c
+++ b/apps/microtvm/zephyr/template_project/src/aot_demo/main.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <tvm/runtime/c_runtime_api.h>
-#include <tvm/runtime/crt/internal/aot_executor/aot_executor.h>
 #include <tvm/runtime/crt/logging.h>
 #include <tvm/runtime/crt/stack_allocator.h>
 #include <unistd.h>
@@ -42,7 +41,6 @@
 #define WORKSPACE_SIZE (270 * 1024)
 
 static uint8_t g_aot_memory[WORKSPACE_SIZE];
-extern tvm_model_t tvmgen_default_network;
 tvm_workspace_t app_workspace;
 
 // Wakeup sequence used to wake up QEMU on the host.
diff --git a/cmake/modules/StandaloneCrt.cmake 
b/cmake/modules/StandaloneCrt.cmake
index 32d7e59..072cba0 100644
--- a/cmake/modules/StandaloneCrt.cmake
+++ b/cmake/modules/StandaloneCrt.cmake
@@ -44,7 +44,6 @@ if(USE_MICRO)
          "src/runtime/crt/include *.h -> include"
          "src/runtime/crt/common *.c -> src/runtime/crt/common"
          "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
-         "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
          "src/runtime/crt/graph_executor_module *.c -> 
src/runtime/crt/graph_executor_module"
          "src/runtime/crt/host *.cc -> template/host"
          "src/runtime/crt/host *.py -> template/host"
@@ -99,7 +98,7 @@ if(USE_MICRO)
     set(make_quiet )
     endif(${VERBOSE})
 
-    list(APPEND crt_libraries memory graph_executor aot_executor 
microtvm_rpc_server microtvm_rpc_common common)  # NOTE: listed in link order.
+    list(APPEND crt_libraries memory graph_executor microtvm_rpc_server 
microtvm_rpc_common common)  # NOTE: listed in link order.
     foreach(crt_lib_name IN LISTS crt_libraries)
       list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
     endforeach()
diff --git a/src/runtime/crt/Makefile b/src/runtime/crt/Makefile
index f458a2f..99efdda 100644
--- a/src/runtime/crt/Makefile
+++ b/src/runtime/crt/Makefile
@@ -68,7 +68,6 @@ endef
 LIBS = \
        src/runtime/crt/common \
        src/runtime/crt/graph_executor \
-       src/runtime/crt/aot_executor \
        src/runtime/crt/graph_executor_module \
        src/runtime/crt/memory \
        src/runtime/crt/microtvm_rpc_common \
diff --git a/src/runtime/crt/aot_executor/aot_executor.c 
b/src/runtime/crt/aot_executor/aot_executor.c
deleted file mode 100644
index d34639b..0000000
--- a/src/runtime/crt/aot_executor/aot_executor.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*!
- * \brief Main entry point for
- * \param model Model descriptor structure to reference for runtime information
- * \param inputs Pointer to input pointer(s)
- * \param outputs Pointer to output pointer(s)
- * \param context Context information to be passed through to operators
- * \return tvm_status_t containing success or errors from the model run
- */
-#include <tvm/runtime/c_runtime_api.h>
-#include <tvm/runtime/crt/internal/aot_executor/aot_executor.h>
-
-tvm_crt_error_t tvm_runtime_run(const tvm_model_t* model, void** inputs, 
void** outputs) {
-  static DLDevice fake_device = {kDLCPU, 0};
-  static int64_t fake_dims = 0;
-  static int64_t fake_shape = {0};
-
-  DLTensor tensors[model->num_input_tensors + model->num_output_tensors];     
// NOLINT
-  TVMValue tvm_values[model->num_input_tensors + model->num_output_tensors];  
// NOLINT
-  int32_t tvm_typeids[model->num_input_tensors + model->num_output_tensors];  
// NOLINT
-
-  for (size_t i = 0; i < model->num_input_tensors; i++) {
-    tensors[i].device = fake_device;
-    tensors[i].data = inputs[i];
-    tensors[i].shape = &fake_shape;
-    tensors[i].ndim = fake_dims;
-    tensors[i].byte_offset = 0;
-    tensors[i].strides = NULL;
-    tvm_values[i].v_handle = &tensors[i];
-  }
-
-  for (size_t i = 0; i < model->num_output_tensors; i++) {
-    size_t j = model->num_input_tensors + i;
-    tensors[j].device = fake_device;
-    tensors[j].data = outputs[i];
-    tensors[j].shape = &fake_shape;
-    tensors[j].ndim = fake_dims;
-    tensors[j].byte_offset = 0;
-    tensors[j].strides = NULL;
-    tvm_values[j].v_handle = &tensors[j];
-  }
-
-  return (tvm_crt_error_t)model->run_func(tvm_values, tvm_typeids, 0, NULL, 0, 
NULL);
-}
diff --git 
a/src/runtime/crt/include/tvm/runtime/crt/internal/aot_executor/aot_executor.h 
b/src/runtime/crt/include/tvm/runtime/crt/internal/aot_executor/aot_executor.h
deleted file mode 100644
index edfd0ec..0000000
--- 
a/src/runtime/crt/include/tvm/runtime/crt/internal/aot_executor/aot_executor.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*!
- * \brief TVM Executor for the Ahead-of-Time Runtime
- *
- * AOT models are described by the TVM model descriptor format
- * which can be passed to tvm_runtime_run. These descriptors will be
- * generated by the AOT compilation process. This can optionally be
- * augmented with platform specific context to be passed to the TVM
- * operators.
- *
- * Example:
- * extern tvm_model_t my_network;
- * int main() {
- *    void* data = get_data();
- *    void* output[4] = {0, 0, 0, 0};
- *    void* inputs = {data};
- *    void* outputs = {output};
- *    tvm_context_t my_context = {
- *      .driver = ...;
- *    };
- *    tvm_runtime_run(
- *      &my_network,
- *      inputs,
- *      outputs
- *      &my_context
- *    );
- *    return 0;
- * }
- */
-
-#ifndef 
TVM_RUNTIME_CRT_INCLUDE_TVM_RUNTIME_CRT_INTERNAL_AOT_EXECUTOR_AOT_EXECUTOR_H_
-#define 
TVM_RUNTIME_CRT_INCLUDE_TVM_RUNTIME_CRT_INTERNAL_AOT_EXECUTOR_AOT_EXECUTOR_H_
-
-#include <stdint.h>
-#include <tvm/runtime/c_backend_api.h>
-#include <tvm/runtime/crt/error_codes.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*!
- * \brief TVM Model descriptor to describe the
- *  model to the runtime.
- */
-typedef struct {
-  size_t num_input_tensors;       /** Number of expected input tensors */
-  size_t num_output_tensors;      /** Number of expected output tensors */
-  TVMBackendPackedCFunc run_func; /** Generated model function, called through 
tvm_runtime_run */
-} tvm_model_t;
-
-/*!
- * \brief Main entry point to execute the AOT runner function
- * \param model Model descriptor structure to reference for runtime information
- * \param inputs Pointer to input pointer(s)
- * \param outputs Pointer to output pointer(s)
- * \return tvm_status_t containing success or errors from the model run
- */
-tvm_crt_error_t tvm_runtime_run(const tvm_model_t* model, void** inputs, 
void** outputs);
-
-#ifdef __cplusplus
-}  // extern "C"
-#endif
-
-#endif  // 
TVM_RUNTIME_CRT_INCLUDE_TVM_RUNTIME_CRT_INTERNAL_AOT_EXECUTOR_AOT_EXECUTOR_H_
diff --git a/tests/crt/aot_executor_test.cc b/tests/crt/aot_executor_test.cc
deleted file mode 100644
index e8afa13..0000000
--- a/tests/crt/aot_executor_test.cc
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <dlpack/dlpack.h>
-#include <gtest/gtest.h>
-#include <tvm/runtime/c_runtime_api.h>
-#include <tvm/runtime/crt/internal/aot_executor/aot_executor.h>
-
-int test_run_func(TVMValue* args, int* arg_type_ids, int num_args, TVMValue* 
out_ret_value,
-                  int* out_ret_tcode, void* resource_handle) {
-  return kTvmErrorNoError;
-}
-
-TEST(AOTRuntime, NoOp) {
-  const tvm_model_t test_model = {
-      .num_input_tensors = 0,
-      .num_output_tensors = 0,
-      .run_func = &test_run_func,
-  };
-
-  ASSERT_EQ(kTvmErrorNoError, tvm_runtime_run(&test_model, NULL, NULL));
-}
-
-int32_t error_run_func(TVMValue* args, int* arg_type_ids, int32_t num_args, 
TVMValue* out_ret_value,
-                       int* out_ret_tcode, void* resource_handle) {
-  return kTvmErrorPlatformNoMemory;
-}
-
-TEST(AOTRuntime, Error) {
-  const tvm_model_t error_model = {
-      .num_input_tensors = 0,
-      .num_output_tensors = 0,
-      .run_func = &error_run_func,
-  };
-
-  ASSERT_EQ(kTvmErrorPlatformNoMemory, tvm_runtime_run(&error_model, NULL, 
NULL));
-}
-
-int32_t identity_run_func(TVMValue* args, int* arg_type_ids, int32_t num_args,
-                          TVMValue* out_ret_value, int* out_ret_tcode, void* 
resource_handle) {
-  void* arg0 = (((TVMValue*)args)[0].v_handle);
-  void* arg1 = (((TVMValue*)args)[1].v_handle);
-  void* placeholder = (((DLTensor*)arg0)[0].data);
-  void* T_id = (((DLTensor*)arg1)[0].data);
-  ((uint32_t*)T_id)[(0)] = ((uint32_t*)placeholder)[(0)];
-  return kTvmErrorNoError;
-}
-
-TEST(AOTRuntime, Identity) {
-  const tvm_model_t identity_model = {
-      .num_input_tensors = 1,
-      .num_output_tensors = 1,
-      .run_func = &identity_run_func,
-  };
-
-  uint32_t inputs1[1] = {404};
-  void* inputs[] = {inputs1};
-  uint32_t outputs1[1];
-  void* outputs[] = {outputs1};
-
-  ASSERT_EQ(kTvmErrorNoError, tvm_runtime_run(&identity_model, inputs, 
outputs));
-  ASSERT_EQ(outputs1[0], 404U);
-}
-
-int32_t add_run_func(TVMValue* args, int* arg_type_ids, int32_t num_args, 
TVMValue* out_ret_value,
-                     int* out_ret_tcode, void* resource_handle) {
-  void* arg0 = (((TVMValue*)args)[0].v_handle);
-  void* arg1 = (((TVMValue*)args)[1].v_handle);
-  void* placeholder = (((DLTensor*)arg0)[0].data);
-  void* T_add = (((DLTensor*)arg1)[0].data);
-  ((uint32_t*)T_add)[(0)] = ((uint32_t*)placeholder)[(0)] + 
((uint32_t*)placeholder)[(1)];
-  return kTvmErrorNoError;
-
-  return kTvmErrorNoError;
-}
-
-TEST(AOTRuntime, Add) {
-  const tvm_model_t add_model = {
-      .num_input_tensors = 1,
-      .num_output_tensors = 1,
-      .run_func = &add_run_func,
-  };
-
-  uint32_t inputs1[2] = {404, 500};
-  void* inputs[] = {inputs1};
-  uint32_t outputs1[1];
-  void* outputs[] = {outputs1};
-
-  ASSERT_EQ(kTvmErrorNoError, tvm_runtime_run(&add_model, inputs, outputs));
-  ASSERT_EQ(outputs1[0], 904U);
-}
-
-int32_t multiple_inputs_run_func(TVMValue* args, int* arg_type_ids, int32_t 
num_args,
-                                 TVMValue* out_ret_value, int* out_ret_tcode,
-                                 void* resource_handle) {
-  void* arg0 = (((TVMValue*)args)[0].v_handle);
-  void* arg1 = (((TVMValue*)args)[1].v_handle);
-  void* arg2 = (((TVMValue*)args)[2].v_handle);
-  void* placeholder = (((DLTensor*)arg0)[0].data);
-  void* placeholder1 = (((DLTensor*)arg1)[0].data);
-  void* T_add = (((DLTensor*)arg2)[0].data);
-  ((uint32_t*)T_add)[(0)] = ((uint32_t*)placeholder)[(0)] + 
((uint32_t*)placeholder)[(1)] +
-                            ((uint32_t*)placeholder1)[(0)] + 
((uint32_t*)placeholder1)[(1)];
-  return kTvmErrorNoError;
-}
-
-TEST(AOTRuntime, MultipleInputs) {
-  const tvm_model_t multiple_inputs_model = {
-      .num_input_tensors = 2,
-      .num_output_tensors = 1,
-      .run_func = &multiple_inputs_run_func,
-  };
-
-  uint32_t inputs1[2] = {404, 500};
-  uint32_t inputs2[2] = {200, 202};
-  void* inputs[] = {inputs1, inputs2};
-
-  uint32_t outputs1[1];
-  void* outputs[] = {outputs1};
-
-  ASSERT_EQ(kTvmErrorNoError, tvm_runtime_run(&multiple_inputs_model, inputs, 
outputs));
-  ASSERT_EQ(outputs1[0], 1306U);
-}
-
-int32_t multiple_outputs_run_func(TVMValue* args, int* arg_type_ids, int32_t 
num_args,
-                                  TVMValue* out_ret_value, int* out_ret_tcode,
-                                  void* resource_handle) {
-  void* arg0 = (((TVMValue*)args)[0].v_handle);
-  void* arg1 = (((TVMValue*)args)[1].v_handle);
-  void* arg2 = (((TVMValue*)args)[2].v_handle);
-  void* placeholder = (((DLTensor*)arg0)[0].data);
-  void* T_split1 = (((DLTensor*)arg1)[0].data);
-  void* T_split2 = (((DLTensor*)arg2)[0].data);
-  ((uint32_t*)T_split1)[(0)] = ((uint32_t*)placeholder)[(0)];
-  ((uint32_t*)T_split2)[(0)] = ((uint32_t*)placeholder)[(1)];
-  return kTvmErrorNoError;
-}
-
-TEST(AOTRuntime, MultipleOutputs) {
-  const tvm_model_t multiple_outputs_model = {
-      .num_input_tensors = 1,
-      .num_output_tensors = 2,
-      .run_func = &multiple_outputs_run_func,
-  };
-
-  uint32_t inputs1[2] = {404, 500};
-  void* inputs[] = {inputs1};
-
-  uint32_t outputs1[1];
-  uint32_t outputs2[1];
-  void* outputs[] = {outputs1, outputs2};
-
-  ASSERT_EQ(kTvmErrorNoError, tvm_runtime_run(&multiple_outputs_model, inputs, 
outputs));
-  ASSERT_EQ(outputs1[0], 404U);
-  ASSERT_EQ(outputs2[0], 500U);
-}
-
-int main(int argc, char** argv) {
-  testing::InitGoogleTest(&argc, argv);
-  testing::FLAGS_gtest_death_test_style = "threadsafe";
-  return RUN_ALL_TESTS();
-}
diff --git a/tests/python/relay/aot/aot_test.mk 
b/tests/python/relay/aot/aot_test.mk
index 0c47a32..04a77f0 100644
--- a/tests/python/relay/aot/aot_test.mk
+++ b/tests/python/relay/aot/aot_test.mk
@@ -42,7 +42,7 @@ aot_test_runner: $(build_dir)/aot_test_runner
 source_libs= $(wildcard $(build_dir)/../codegen/host/src/*.c)
 lib_objs =$(source_libs:.c=.o)
 
-$(build_dir)/aot_test_runner: $(build_dir)/test.c  $(build_dir)/aot_executor.o 
 $(source_libs) $(build_dir)/stack_allocator.o $(build_dir)/crt_backend_api.o
+$(build_dir)/aot_test_runner: $(build_dir)/test.c  $(source_libs) 
$(build_dir)/stack_allocator.o $(build_dir)/crt_backend_api.o
        $(QUIET)mkdir -p $(@D)
        $(QUIET)$(CC) $(CFLAGS) $(PKG_CFLAGS) -o $@ $^ $(PKG_LDFLAGS) 
$(BACKTRACE_LDFLAGS) $(BACKTRACE_CFLAGS) -lm
 
@@ -50,10 +50,6 @@ $(build_dir)/%.o: $(build_dir)/../codegen/host/src/%.c
        $(QUIET)mkdir -p $(@D)
        $(QUIET)$(CC) $(CFLAGS) -c $(PKG_CFLAGS) -o $@  $^ $(BACKTRACE_CFLAGS)
 
-$(build_dir)/aot_executor.o: 
$(STANDALONE_CRT_DIR)/src/runtime/crt/aot_executor/aot_executor.c
-       $(QUIET)mkdir -p $(@D)
-       $(QUIET)$(CC) $(CFLAGS) -c $(PKG_CFLAGS) -o $@  $^ $(BACKTRACE_CFLAGS)
-
 $(build_dir)/stack_allocator.o: 
$(STANDALONE_CRT_DIR)/src/runtime/crt/memory/stack_allocator.c
        $(QUIET)mkdir -p $(@D)
        $(QUIET)$(CC) $(CFLAGS) -c $(PKG_CFLAGS) -o $@  $^ $(BACKTRACE_CFLAGS)

Reply via email to