Skip to content

Commit 3fbf008

Browse files
committed
removed weak
1 parent f044da2 commit 3fbf008

File tree

7 files changed

+118
-57
lines changed

7 files changed

+118
-57
lines changed

apps/microtvm/arduino/template_project/src/example_project/platform.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tvm_workspace_t app_workspace;
3434

3535
// Called when an internal error occurs and execution cannot continue.
3636
// Blink code for debugging purposes
37-
__attribute__((weak)) void TVMPlatformAbort(tvm_crt_error_t error) {
37+
void TVMPlatformAbort(tvm_crt_error_t error) {
3838
TVMLogf("TVMPlatformAbort: 0x%08x\n", error);
3939
for (;;) {
4040
#ifdef LED_BUILTIN
@@ -51,13 +51,12 @@ __attribute__((weak)) void TVMPlatformAbort(tvm_crt_error_t error) {
5151
}
5252

5353
// Allocate memory for use by TVM.
54-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev,
55-
void** out_ptr) {
54+
tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
5655
return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr);
5756
}
5857

5958
// Free memory used by TVM.
60-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
59+
tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
6160
return StackMemoryManager_Free(&app_workspace, ptr);
6261
}
6362

@@ -68,7 +67,7 @@ unsigned long g_utvm_start_time_micros;
6867
int g_utvm_timer_running = 0;
6968

7069
// Start a device timer.
71-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
70+
tvm_crt_error_t TVMPlatformTimerStart() {
7271
if (g_utvm_timer_running) {
7372
return kTvmErrorPlatformTimerBadState;
7473
}
@@ -78,7 +77,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
7877
}
7978

8079
// Stop the running device timer and get the elapsed time (in microseconds).
81-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
80+
tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
8281
if (!g_utvm_timer_running) {
8382
return kTvmErrorPlatformTimerBadState;
8483
}
@@ -89,15 +88,15 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_
8988
}
9089

9190
// Fill a buffer with random data.
92-
__attribute__((weak)) tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
91+
tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
9392
for (size_t i = 0; i < num_bytes; i++) {
9493
buffer[i] = rand();
9594
}
9695
return kTvmErrorNoError;
9796
}
9897

9998
// Initialize TVM inference.
100-
__attribute__((weak)) tvm_crt_error_t TVMPlatformInitialize() {
99+
tvm_crt_error_t TVMPlatformInitialize() {
101100
StackMemoryManager_Init(&app_workspace, g_aot_memory, WORKSPACE_SIZE);
102101
return kTvmErrorNoError;
103102
}

apps/microtvm/arduino/template_project/src/host_driven/platform.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,20 @@
2626
#include "stdarg.h"
2727

2828
// Called when an internal error occurs and execution cannot continue.
29-
__attribute__((weak)) void TVMPlatformAbort(tvm_crt_error_t error) {
29+
void TVMPlatformAbort(tvm_crt_error_t error) {
3030
TVMLogf("TVMPlatformAbort: 0x%08x\n", error);
3131
for (;;)
3232
;
3333
}
3434

3535
// Called by the microTVM RPC server to implement TVMLogf.
36-
__attribute__((weak)) size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes,
37-
const char* fmt, va_list args) {
36+
size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt,
37+
va_list args) {
3838
return vsnprintf(out_buf, out_buf_size_bytes, fmt, args);
3939
}
4040

4141
// Allocate memory for use by TVM.
42-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev,
43-
void** out_ptr) {
42+
tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
4443
if (num_bytes == 0) {
4544
num_bytes = sizeof(int);
4645
}
@@ -49,7 +48,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes
4948
}
5049

5150
// Free memory used by TVM.
52-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
51+
tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
5352
free(ptr);
5453
return kTvmErrorNoError;
5554
}
@@ -58,7 +57,7 @@ unsigned long g_utvm_start_time_micros;
5857
int g_utvm_timer_running = 0;
5958

6059
// Start a device timer.
61-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
60+
tvm_crt_error_t TVMPlatformTimerStart() {
6261
if (g_utvm_timer_running) {
6362
return kTvmErrorPlatformTimerBadState;
6463
}
@@ -68,7 +67,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
6867
}
6968

7069
// Stop the running device timer and get the elapsed time (in microseconds).
71-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
70+
tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
7271
if (!g_utvm_timer_running) {
7372
return kTvmErrorPlatformTimerBadState;
7473
}
@@ -79,7 +78,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_
7978
}
8079

8180
// Fill a buffer with random data.
82-
__attribute__((weak)) tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
81+
tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
8382
for (size_t i = 0; i < num_bytes; i++) {
8483
buffer[i] = rand();
8584
}

apps/microtvm/zephyr/template_project/src/aot_standalone_demo/platform.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,33 @@ struct k_timer g_microtvm_timer;
4444
uint32_t g_microtvm_start_time;
4545
int g_microtvm_timer_running = 0;
4646

47-
__attribute__((weak)) size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes,
48-
const char* fmt, va_list args) {
47+
size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt,
48+
va_list args) {
4949
return vsnprintk(out_buf, out_buf_size_bytes, fmt, args);
5050
}
5151

52-
__attribute__((weak)) void TVMPlatformAbort(tvm_crt_error_t error) {
52+
void TVMPlatformAbort(tvm_crt_error_t error) {
5353
TVMLogf("TVMPlatformAbort: %08x\n", error);
5454
sys_reboot(SYS_REBOOT_COLD);
5555
for (;;)
5656
;
5757
}
5858

59-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev,
60-
void** out_ptr) {
59+
tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
6160
return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr);
6261
}
6362

64-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
63+
tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
6564
return StackMemoryManager_Free(&app_workspace, ptr);
6665
}
6766

68-
__attribute__((weak)) tvm_crt_error_t TVMPlatformInitialize() {
67+
tvm_crt_error_t TVMPlatformInitialize() {
6968
k_timer_init(&g_microtvm_timer, NULL, NULL);
7069
StackMemoryManager_Init(&app_workspace, g_aot_memory, WORKSPACE_SIZE);
7170
return kTvmErrorNoError;
7271
}
7372

74-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
73+
tvm_crt_error_t TVMPlatformTimerStart() {
7574
if (g_microtvm_timer_running) {
7675
TVMLogf("timer already running");
7776
return kTvmErrorPlatformTimerBadState;
@@ -83,7 +82,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
8382
return kTvmErrorNoError;
8483
}
8584

86-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
85+
tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
8786
if (!g_microtvm_timer_running) {
8887
TVMLogf("timer not running");
8988
return kTvmErrorSystemErrorMask | 2;

apps/microtvm/zephyr/template_project/src/host_driven/platform.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t* esf) {
5555
;
5656
}
5757

58-
__attribute__((weak)) void TVMPlatformAbort(tvm_crt_error_t error) {
58+
void TVMPlatformAbort(tvm_crt_error_t error) {
5959
TVMLogf("TVMError: 0x%x", error);
6060
sys_reboot(SYS_REBOOT_COLD);
6161
#ifdef CONFIG_LED
@@ -65,24 +65,23 @@ __attribute__((weak)) void TVMPlatformAbort(tvm_crt_error_t error) {
6565
;
6666
}
6767

68-
__attribute__((weak)) size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes,
69-
const char* fmt, va_list args) {
68+
size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt,
69+
va_list args) {
7070
return vsnprintk(out_buf, out_buf_size_bytes, fmt, args);
7171
}
7272

73-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev,
74-
void** out_ptr) {
73+
tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
7574
*out_ptr = k_heap_alloc(&tvm_heap, num_bytes, K_NO_WAIT);
7675
return (*out_ptr == NULL) ? kTvmErrorPlatformNoMemory : kTvmErrorNoError;
7776
}
7877

79-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
78+
tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
8079
k_heap_free(&tvm_heap, ptr);
8180
return kTvmErrorNoError;
8281
}
8382

8483
// Called to start system timer.
85-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
84+
tvm_crt_error_t TVMPlatformTimerStart() {
8685
if (g_microtvm_timer_running) {
8786
TVMLogf("timer already running");
8887
return kTvmErrorPlatformTimerBadState;
@@ -97,7 +96,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStart() {
9796
}
9897

9998
// Called to stop system timer.
100-
__attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
99+
tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
101100
if (!g_microtvm_timer_running) {
102101
TVMLogf("timer not running");
103102
return kTvmErrorSystemErrorMask | 2;
@@ -115,7 +114,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_
115114
return kTvmErrorNoError;
116115
}
117116

118-
__attribute__((weak)) tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
117+
tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
119118
uint32_t random; // one unit of random data.
120119

121120
// Fill parts of `buffer` which are as large as `random`.
@@ -134,7 +133,7 @@ __attribute__((weak)) tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer,
134133
return kTvmErrorNoError;
135134
}
136135

137-
__attribute__((weak)) tvm_crt_error_t TVMPlatformInitialize() {
136+
tvm_crt_error_t TVMPlatformInitialize() {
138137
#ifdef CONFIG_LED
139138
if (!device_is_ready(led0.port)) {
140139
for (;;)

apps/microtvm/zephyr/template_project/src/mlperftiny/platform.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,27 @@
4242
static uint8_t g_aot_memory[WORKSPACE_SIZE];
4343
tvm_workspace_t app_workspace;
4444

45-
__attribute__((weak)) size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes,
46-
const char* fmt, va_list args) {
45+
size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt,
46+
va_list args) {
4747
return vsnprintk(out_buf, out_buf_size_bytes, fmt, args);
4848
}
4949

50-
__attribute__((weak)) void TVMPlatformAbort(tvm_crt_error_t error) {
50+
void TVMPlatformAbort(tvm_crt_error_t error) {
5151
TVMLogf("TVMPlatformAbort: %08x\n", error);
5252
sys_reboot(SYS_REBOOT_COLD);
5353
for (;;)
5454
;
5555
}
5656

57-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev,
58-
void** out_ptr) {
57+
tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
5958
return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr);
6059
}
6160

62-
__attribute__((weak)) tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
61+
tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
6362
return StackMemoryManager_Free(&app_workspace, ptr);
6463
}
6564

66-
__attribute__((weak)) tvm_crt_error_t TVMPlatformInitialize() {
65+
tvm_crt_error_t TVMPlatformInitialize() {
6766
StackMemoryManager_Init(&app_workspace, g_aot_memory, WORKSPACE_SIZE);
6867
return kTvmErrorNoError;
6968
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/*!
21+
* \\file tvm/runtime/crt_config.h
22+
* \\brief Template for CRT configuration, to be modified on each target.
23+
*/
24+
#ifndef TVM_RUNTIME_CRT_CRT_CONFIG_H_
25+
#define TVM_RUNTIME_CRT_CRT_CONFIG_H_
26+
27+
/*! Log level of the CRT runtime */
28+
#define TVM_CRT_LOG_LEVEL TVM_CRT_LOG_LEVEL_DEBUG
29+
30+
/*! Support low-level debugging in MISRA-C runtime */
31+
#define TVM_CRT_DEBUG 0
32+
33+
/*! Maximum supported dimension in NDArray */
34+
#define TVM_CRT_MAX_NDIM 6
35+
36+
/*! Maximum supported arguments in generated functions */
37+
#define TVM_CRT_MAX_ARGS 10
38+
39+
/*! Size of the global function registry, in bytes. */
40+
#define TVM_CRT_GLOBAL_FUNC_REGISTRY_SIZE_BYTES 512
41+
42+
/*! Maximum number of registered modules. */
43+
#define TVM_CRT_MAX_REGISTERED_MODULES 2
44+
45+
/*! Maximum packet size, in bytes, including the length header. */
46+
#define TVM_CRT_MAX_PACKET_SIZE_BYTES 2048
47+
48+
/*! Maximum supported string length in dltype, e.g. "int8", "int16", "float32" */
49+
#define TVM_CRT_MAX_STRLEN_DLTYPE 10
50+
51+
/*! Maximum supported string length in function names */
52+
#define TVM_CRT_MAX_STRLEN_FUNCTION_NAME 120
53+
54+
/*! Maximum supported string length in parameter names */
55+
#define TVM_CRT_MAX_STRLEN_PARAM_NAME 80
56+
57+
/*! Maximum length of a PackedFunc function name. */
58+
#define TVM_CRT_MAX_FUNCTION_NAME_LENGTH_BYTES 30
59+
60+
/*! Enable checks to enforce the stack allocator with a FIFO ordering. Off by default */
61+
// #define TVM_CRT_STACK_ALLOCATOR_ENABLE_FIFO_CHECK
62+
63+
/*! Log2 of the page size (bytes) for a virtual memory page. */
64+
#define TVM_CRT_PAGE_BITS 10
65+
66+
/*! Number of pages on device. */
67+
#define TVM_CRT_MAX_PAGES 300
68+
69+
#endif // TVM_RUNTIME_CRT_CRT_CONFIG_H_

0 commit comments

Comments
 (0)