Compare commits

..

No commits in common. "main" and "WAMR-2.4.1" have entirely different histories.

34 changed files with 150 additions and 430 deletions

View File

@ -32,60 +32,60 @@ on:
required: false
env:
DEFAULT_BUILD_OPTIONS:
DEFAULT_BUILD_OPTIONS:
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1"
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1"
GC_EH_BUILD_OPTIONS:
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1 \
-DWAMR_BUILD_EXCE_HANDLING=1 \
-DWAMR_BUILD_GC=1"
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1 \
-DWAMR_BUILD_EXCE_HANDLING=1 \
-DWAMR_BUILD_GC=1"
permissions:
contents: read
@ -97,9 +97,9 @@ jobs:
matrix:
include:
- build_options: $DEFAULT_BUILD_OPTIONS
suffix: ""
suffix: ''
- build_options: $GC_EH_BUILD_OPTIONS
suffix: "-gc-eh"
suffix: '-gc-eh'
permissions:
contents: write # for uploading release artifacts
@ -126,30 +126,6 @@ jobs:
cmake --build build --config Release --parallel 4
working-directory: ${{ inputs.cwd }}
- name: smoke test on non-Windows
if: ${{ !startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/iwasm ]]; then
echo "iwasm binary is not found in the expected location."
exit 1
fi
build/iwasm --version
working-directory: ${{ inputs.cwd }}
- name: smoke test on Windows
if: ${{ startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/Release/iwasm ]]; then
echo "iwasm binary is not found in the expected location."
exit 1
fi
build/Release/iwasm --version
working-directory: ${{ inputs.cwd }}
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest'
run: |

View File

@ -62,30 +62,6 @@ jobs:
cmake --build build --config Release --parallel 4
working-directory: wamr-compiler
- name: smoke test on non-windows
if: ${{ !startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/wamrc ]]; then
echo "wamrc binary is not found in the expected location."
exit 1
fi
build/wamrc --version
working-directory: wamr-compiler
- name: smoke test on Windows
if: ${{ startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/Release/wamrc ]]; then
echo "wamrc binary is not found in the expected location."
exit 1
fi
build/Release/wamrc --version
working-directory: wamr-compiler
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest' && inputs.release
run: |

View File

@ -53,7 +53,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3.29.4
uses: github/codeql-action/init@v3.29.3
with:
languages: ${{ matrix.language }}
@ -70,7 +70,7 @@ jobs:
- run: |
./.github/scripts/codeql_buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.29.4
uses: github/codeql-action/analyze@v3.29.3
with:
category: "/language:${{matrix.language}}"
upload: false
@ -99,7 +99,7 @@ jobs:
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v3.29.4
uses: github/codeql-action/upload-sarif@v3.29.3
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}"

View File

@ -371,47 +371,6 @@ jobs:
ctest
working-directory: tests/unit
build_regression_tests:
needs:
[build_llvm_libraries_on_ubuntu_2204]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Get LLVM libraries
id: retrieve_llvm_libs
uses: actions/cache@v4
with:
path: |
./core/deps/llvm/build/bin
./core/deps/llvm/build/include
./core/deps/llvm/build/lib
./core/deps/llvm/build/libexec
./core/deps/llvm/build/share
key: ${{ matrix.llvm_cache_key }}
- name: Quit if cache miss
if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: Build wamrc and iwasm
run: |
./build_wamr.sh
working-directory: tests/regression/ba-issues
- name: Run regression tests
run: |
python run.py
working-directory: tests/regression/ba-issues
build_samples_wasm_c_api:
needs:
[

View File

@ -60,6 +60,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@701df0e49d84a24bd8f0d01f80c0dbf69ab07674
uses: github/codeql-action/upload-sarif@7710ed11e398ea99c7f7004c2b2e0f580458db42
with:
sarif_file: results.sarif

View File

@ -1786,8 +1786,7 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
read_uint32(buf, buf_end, j);
#if WASM_ENABLE_AOT_VALIDATOR != 0
/* an equivalence type should be before the type it refers to */
if (j > i) {
if (j >= module->type_count) {
set_error_buf(error_buf, error_buf_size, "invalid type index");
goto fail;
}
@ -1806,12 +1805,7 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
read_uint32(buf, buf_end, parent_type_idx);
read_uint16(buf, buf_end, rec_count);
read_uint16(buf, buf_end, rec_idx);
#if WASM_ENABLE_AOT_VALIDATOR != 0
if (rec_idx > i) {
set_error_buf(error_buf, error_buf_size, "invalid rec_idx");
goto fail;
}
#endif
if (type_flag == WASM_TYPE_FUNC) {
AOTFuncType *func_type;

View File

@ -1,3 +0,0 @@
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -79,6 +79,3 @@ return:
add sp, sp, #0x30 /* restore sp */
ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -77,6 +77,3 @@ return:
add sp, sp, #0x30 /* restore sp */
ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -67,6 +67,3 @@ call_func:
j_s [blink] /* ret */
nop_s
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -73,6 +73,3 @@ return:
add sp, sp, #4
ldmfd sp!, {r4, r5, r6, r7, lr}
bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -84,6 +84,3 @@ return:
ldmfd sp!, {r4, r5, r6, r7, lr}
bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -62,6 +62,3 @@ push_args_end:
leave
ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -62,6 +62,3 @@ push_args_end:
leave
ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -35,6 +35,3 @@ skip_push_args:
leave
ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -72,6 +72,3 @@ done:
j $31
.end invokeNative
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -15,4 +15,4 @@
#else
#include "invokeNative_em64_simd.s"
#endif
#endif
#endif

View File

@ -89,6 +89,3 @@ return:
pop {r4, r5, r6, r7}
mov lr, r3
bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -98,6 +98,3 @@ return:
mov lr, r3
bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -72,6 +72,3 @@ call_func:
return:
retw.n
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -199,8 +199,6 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args)
heap->heap_handle = NULL;
heap->base_addr = init_args->pre_allocated_addr;
LOG_VERBOSE("Create preallocated shared heap %p with size %u",
heap->base_addr, size);
}
else {
if (!(heap->heap_handle =
@ -227,8 +225,6 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args)
LOG_WARNING("init share heap failed");
goto fail4;
}
LOG_VERBOSE("Create pool shared heap %p with size %u", heap->base_addr,
size);
}
os_mutex_lock(&shared_heap_list_lock);
@ -513,8 +509,6 @@ wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst,
os_mutex_lock(&shared_heap_list_lock);
shared_heap->attached_count++;
os_mutex_unlock(&shared_heap_list_lock);
LOG_VERBOSE("Shared heap %p is attached to module instance %p", shared_heap,
module_inst);
return true;
}
@ -576,7 +570,6 @@ wasm_runtime_detach_shared_heap_internal(WASMModuleInstanceCommon *module_inst)
e->shared_heap_base_addr_adj = NULL;
}
#endif /* end of WASM_ENABLE_AOT != 0 */
LOG_VERBOSE("Shared heap is detached from module instance %p", module_inst);
}
void

View File

@ -400,7 +400,8 @@ check_array_type(const WASMModule *module, uint32 type_index, char *error_buf,
error_buf_size)) {
return false;
}
if (module->types[type_index]->type_flag != WASM_TYPE_ARRAY) {
if (module->types[type_index] == NULL
|| module->types[type_index]->type_flag != WASM_TYPE_ARRAY) {
set_error_buf(error_buf, error_buf_size, "unknown array type");
return false;
}
@ -423,7 +424,8 @@ check_function_type(const WASMModule *module, uint32 type_index,
}
#if WASM_ENABLE_GC != 0
if (module->types[type_index]->type_flag != WASM_TYPE_FUNC) {
if (module->types[type_index] == NULL
|| module->types[type_index]->type_flag != WASM_TYPE_FUNC) {
set_error_buf(error_buf, error_buf_size, "unknown function type");
return false;
}
@ -1255,8 +1257,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
error_buf_size)) {
goto fail;
}
if (module->types[type_idx]->type_flag
!= WASM_TYPE_STRUCT) {
if (module->types[type_idx] == NULL
|| module->types[type_idx]->type_flag
!= WASM_TYPE_STRUCT) {
set_error_buf(error_buf, error_buf_size,
"unknown struct type");
goto fail;
@ -2496,13 +2499,6 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
#endif /* end of WASM_ENABLE_GC == 0 */
}
for (i = 0; i < module->type_count; i++) {
if (module->types[i] == NULL) {
set_error_buf_v(error_buf, error_buf_size, "unknown type %d", i);
return false;
}
}
if (p != p_end) {
set_error_buf(error_buf, error_buf_size, "section size mismatch");
return false;
@ -12689,7 +12685,9 @@ re_scan:
error_buf, error_buf_size)) {
goto fail;
}
if (module->types[type_idx1]->type_flag != WASM_TYPE_FUNC) {
if (module->types[type_idx1] == NULL
|| module->types[type_idx1]->type_flag
!= WASM_TYPE_FUNC) {
set_error_buf(error_buf, error_buf_size,
"unknown function type");
goto fail;
@ -12706,7 +12704,9 @@ re_scan:
error_buf, error_buf_size)) {
goto fail;
}
if (module->types[type_idx]->type_flag != WASM_TYPE_FUNC) {
if (module->types[type_idx] == NULL
|| module->types[type_idx]->type_flag
!= WASM_TYPE_FUNC) {
set_error_buf(error_buf, error_buf_size,
"unknown function type");
goto fail;
@ -14542,8 +14542,9 @@ re_scan:
error_buf_size)) {
goto fail;
}
if (module->types[type_idx]->type_flag
!= WASM_TYPE_STRUCT) {
if (module->types[type_idx] == NULL
|| module->types[type_idx]->type_flag
!= WASM_TYPE_STRUCT) {
set_error_buf(error_buf, error_buf_size,
"unknown struct type");
goto fail;
@ -14629,8 +14630,9 @@ re_scan:
error_buf_size)) {
goto fail;
}
if (module->types[type_idx]->type_flag
!= WASM_TYPE_STRUCT) {
if (module->types[type_idx] == NULL
|| module->types[type_idx]->type_flag
!= WASM_TYPE_STRUCT) {
set_error_buf(error_buf, error_buf_size,
"unknown struct type");
goto fail;

View File

@ -219,9 +219,6 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
void
freeaddrinfo(struct addrinfo *res);
const char *
gai_strerror(int code);
#endif
/**

View File

@ -590,28 +590,6 @@ freeaddrinfo(struct addrinfo *res)
free(res);
}
const char *
gai_strerror(int code)
{
switch (code) {
#define ERR(a) \
case a: \
return #a
ERR(EAI_AGAIN);
ERR(EAI_BADFLAGS);
ERR(EAI_FAIL);
ERR(EAI_FAMILY);
ERR(EAI_MEMORY);
ERR(EAI_NONAME);
ERR(EAI_OVERFLOW);
ERR(EAI_SERVICE);
ERR(EAI_SOCKTYPE);
ERR(EAI_SYSTEM);
#undef ERR
}
return "Unknown error";
}
static struct timeval
time_us_to_timeval(uint64_t time_us)
{

View File

@ -507,35 +507,10 @@ fail:
return res;
}
static wasi_nn_error
copyin_and_nul_terminate(wasm_module_inst_t inst, char *name, uint32_t name_len,
char **resultp)
{
char *nul_terminated_name;
if (!wasm_runtime_validate_native_addr(inst, name, name_len)) {
return invalid_argument;
}
nul_terminated_name = wasm_runtime_malloc(name_len + 1);
if (nul_terminated_name == NULL) {
return runtime_error;
}
bh_memcpy_s(nul_terminated_name, name_len + 1, name, name_len);
nul_terminated_name[name_len] = '\0'; /* ensure NUL termination */
if (strlen(nul_terminated_name) != name_len) {
/* reject names containing '\0' for now */
wasm_runtime_free(nul_terminated_name);
return invalid_argument;
}
*resultp = nul_terminated_name;
return success;
}
wasi_nn_error
wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
graph *g)
{
WASINNContext *wasi_nn_ctx = NULL;
char *nul_terminated_name = NULL;
wasi_nn_error res;
wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env);
@ -543,21 +518,25 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
return runtime_error;
}
if (!wasm_runtime_validate_native_addr(instance, name, name_len)) {
NN_ERR_PRINTF("name is invalid");
return invalid_argument;
}
if (!wasm_runtime_validate_native_addr(instance, g,
(uint64)sizeof(graph))) {
NN_ERR_PRINTF("graph is invalid");
return invalid_argument;
}
res = copyin_and_nul_terminate(instance, name, name_len,
&nul_terminated_name);
if (res != success) {
goto fail;
if (name_len == 0 || name[name_len] != '\0') {
NN_ERR_PRINTF("Invalid filename");
return invalid_argument;
}
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME %s...", nul_terminated_name);
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME %s...", name);
wasi_nn_ctx = lock_ctx(instance);
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
@ -568,20 +547,14 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
goto fail;
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res,
wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
g);
wasi_nn_ctx->backend_ctx, name, name_len, g);
if (res != success)
goto fail;
wasi_nn_ctx->is_model_loaded = true;
res = success;
fail:
if (nul_terminated_name != NULL) {
wasm_runtime_free(nul_terminated_name);
}
if (wasi_nn_ctx != NULL) {
unlock_ctx(wasi_nn_ctx);
}
unlock_ctx(wasi_nn_ctx);
return res;
}
@ -590,9 +563,6 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
int32_t name_len, char *config,
int32_t config_len, graph *g)
{
WASINNContext *wasi_nn_ctx = NULL;
char *nul_terminated_name = NULL;
char *nul_terminated_config = NULL;
wasi_nn_error res;
wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env);
@ -600,27 +570,30 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
return runtime_error;
}
if (!wasm_runtime_validate_native_addr(instance, name, name_len)) {
NN_ERR_PRINTF("name is invalid");
return invalid_argument;
}
if (!wasm_runtime_validate_native_addr(instance, g,
(uint64)sizeof(graph))) {
NN_ERR_PRINTF("graph is invalid");
return invalid_argument;
}
res = copyin_and_nul_terminate(instance, name, name_len,
&nul_terminated_name);
if (res != success) {
goto fail;
}
res = copyin_and_nul_terminate(instance, config, config_len,
&nul_terminated_config);
if (res != success) {
goto fail;
if (name_len == 0 || name[name_len] != '\0') {
NN_ERR_PRINTF("Invalid filename");
return invalid_argument;
}
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME_WITH_CONFIG %s %s...",
nul_terminated_name, nul_terminated_config);
if (!config || config_len == 0 || config[config_len] != '\0') {
NN_ERR_PRINTF("Invalid config");
return invalid_argument;
}
wasi_nn_ctx = lock_ctx(instance);
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME_WITH_CONFIG %s %s...", name, config);
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
@ -632,23 +605,15 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
;
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name_with_config, res,
wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
nul_terminated_config, config_len, g);
wasi_nn_ctx->backend_ctx, name, name_len, config,
config_len, g);
if (res != success)
goto fail;
wasi_nn_ctx->is_model_loaded = true;
res = success;
fail:
if (nul_terminated_name != NULL) {
wasm_runtime_free(nul_terminated_name);
}
if (nul_terminated_config != NULL) {
wasm_runtime_free(nul_terminated_config);
}
if (wasi_nn_ctx != NULL) {
unlock_ctx(wasi_nn_ctx);
}
unlock_ctx(wasi_nn_ctx);
return res;
}

View File

@ -9,7 +9,6 @@
#include "wasi_nn_backend.h"
#include "wasm_export.h"
#include <tensorflow/lite/c/c_api.h>
#include <tensorflow/lite/interpreter.h>
#include <tensorflow/lite/kernels/register.h>
#include <tensorflow/lite/model.h>
@ -280,53 +279,29 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
tensor *input_tensor)
{
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
TfLiteType tfl_type;
switch (input_tensor->type) {
case fp32:
tfl_type = TfLiteType::kTfLiteFloat32;
break;
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
case u8:
tfl_type = TfLiteType::kTfLiteUInt8;
break;
#endif
default:
NN_ERR_PRINTF("unsupported input tensor type %u",
input_tensor->type);
return runtime_error;
if (input_tensor->type != fp32) {
NN_ERR_PRINTF("unsupported input tensor type %u", input_tensor->type);
return runtime_error;
}
wasi_nn_error res;
if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx)))
return res;
auto interpreter = tfl_ctx->interpreters[ctx].interpreter.get();
uint32_t num_tensors = interpreter->inputs().size();
uint32_t num_tensors =
tfl_ctx->interpreters[ctx].interpreter->inputs().size();
NN_DBG_PRINTF("Number of tensors (%d)", num_tensors);
if (index + 1 > num_tensors) {
return runtime_error;
}
auto tensor = interpreter->input_tensor(index);
auto tensor = tfl_ctx->interpreters[ctx].interpreter->input_tensor(index);
if (tensor == NULL) {
NN_ERR_PRINTF("Missing memory");
return too_large;
}
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
if (TfLiteTensorType(tensor) != tfl_type) {
NN_ERR_PRINTF("Type mismatch");
return runtime_error;
}
if (TfLiteTensorCopyFromBuffer(tensor, input_tensor->data.buf,
input_tensor->data.size)
!= kTfLiteOk) {
return runtime_error;
}
#else
uint32_t model_tensor_size = 1;
for (int i = 0; i < tensor->dims->size; ++i)
model_tensor_size *= (uint32_t)tensor->dims->data[i];
@ -371,7 +346,6 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
it[i] = (uint8_t)(input_tensor_f[i] / scale + zero_point);
}
}
#endif
return success;
}
@ -414,19 +388,14 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
return too_large;
}
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
size_t sz = TfLiteTensorByteSize(tensor);
if (output_tensor->size < sz) {
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large;
}
if (TfLiteTensorCopyToBuffer(tensor, output_tensor->buf, sz) != kTfLiteOk) {
return runtime_error;
}
*output_tensor_size = sz;
#else
if (tensor->quantization.type == kTfLiteNoQuantization) {
NN_DBG_PRINTF("No quantization information");
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
if (output_tensor->size < tensor->bytes) {
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large;
}
#else
/*
* for now, maintain the bug-to-bug compatibility with the old abi,
* where the size here is the number of fp32, not bytes.
@ -435,13 +404,18 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large;
}
#endif
bh_memcpy_s(output_tensor->buf, output_tensor->size, tensor->data.data,
tensor->bytes);
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
*output_tensor_size = tensor->bytes;
#else
/*
* for now, maintain the bug-to-bug compatibility with the old abi,
* where the size here is the number of fp32, not bytes.
*/
*output_tensor_size = tensor->bytes / sizeof(float);
#endif
}
else { // TODO: Assuming uint8 quantized networks.
TfLiteAffineQuantization *quant_info =
@ -455,6 +429,12 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
for (int i = 0; i < (int)tensor->dims->size; ++i)
model_tensor_size *= (uint32_t)tensor->dims->data[i];
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
if (output_tensor->size / sizeof(float) < model_tensor_size) {
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large;
}
#else
/*
* for now, maintain the bug-to-bug compatibility with the old abi,
* where the size here is the number of fp32, not bytes.
@ -463,6 +443,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large;
}
#endif
uint8_t *ot = tfl_ctx->interpreters[ctx]
.interpreter->typed_output_tensor<uint8_t>(index);
@ -477,13 +458,16 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
output_tensor_f[i] = (ot[i] - zero_point) * scale;
}
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
*output_tensor_size = model_tensor_size * sizeof(float);
#else
/*
* for now, maintain the bug-to-bug compatibility with the old abi,
* where the size here is the number of fp32, not bytes.
*/
*output_tensor_size = model_tensor_size;
}
#endif
}
return success;
}

View File

@ -110,13 +110,6 @@ os_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
targ->start = start;
targ->arg = arg;
#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM
esp_pthread_cfg_t default_config = esp_pthread_get_default_config();
default_config.stack_alloc_caps = MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM;
ESP_ERROR_CHECK(esp_pthread_set_cfg(&default_config));
#endif
if (pthread_create(tid, &tattr, os_thread_wrapper, targ) != 0) {
pthread_attr_destroy(&tattr);
os_free(targ);

View File

@ -382,11 +382,9 @@ a non-compatible`AOT_CURRENT_VERSION`.
We try our best to maintain our runtime ABI for AoT-compiled modules
compatible among WAMR versions with compatible `AOT_CURRENT_VERSION`
so that combinations of older wamrc and newer runtime usually work.
However, there might be minor incompatibilities from time to time. For
example, we usually avoid bumping the version when making a change which
affects only a small fraction of users. For productions, we recommend
using exactly same versions of wamrc and the runtime.
However, there might be minor incompatibilities time to time.
For productions, we recommend to use compatible versions of
wamrc and the runtime.
| WAMR version | AOT_CURRENT_VERSION | Compatible AOT version | |
| ------------ | ------------------- | ---------------------- | ---------------------- |

View File

@ -57,10 +57,6 @@ print_help(void)
#else
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n");
#endif
#if WASM_ENABLE_SHARED_HEAP != 0
printf(" --shared-heap-size=n Create shared heap of n bytes and attach to the wasm app.\n");
printf(" The size n will be adjusted to a minumum number aligned to page size\n");
#endif
#if WASM_ENABLE_FAST_JIT != 0
printf(" --jit-codecache-size=n Set fast jit maximum code cache size in bytes,\n");
printf(" default is %u KB\n", FAST_JIT_DEFAULT_CODE_CACHE_SIZE / 1024);
@ -582,11 +578,6 @@ main(int argc, char *argv[])
#else
uint32 heap_size = 16 * 1024;
#endif
#if WASM_ENABLE_SHARED_HEAP != 0
SharedHeapInitArgs heap_init_args;
uint32 shared_heap_size = 0;
void *shared_heap = NULL;
#endif
#if WASM_ENABLE_FAST_JIT != 0
uint32 jit_code_cache_size = FAST_JIT_DEFAULT_CODE_CACHE_SIZE;
#endif
@ -694,13 +685,6 @@ main(int argc, char *argv[])
return print_help();
heap_size = atoi(argv[0] + 12);
}
#if WASM_ENABLE_SHARED_HEAP != 0
else if (!strncmp(argv[0], "--shared-heap-size=", 19)) {
if (argv[0][19] == '\0')
return print_help();
shared_heap_size = atoi(argv[0] + 19);
}
#endif
#if WASM_ENABLE_FAST_JIT != 0
else if (!strncmp(argv[0], "--jit-codecache-size=", 21)) {
if (argv[0][21] == '\0')
@ -1023,24 +1007,6 @@ main(int argc, char *argv[])
}
#endif
#if WASM_ENABLE_SHARED_HEAP != 0
if (shared_heap_size > 0) {
memset(&heap_init_args, 0, sizeof(heap_init_args));
heap_init_args.size = shared_heap_size;
shared_heap = wasm_runtime_create_shared_heap(&heap_init_args);
if (!shared_heap) {
printf("Create preallocated shared heap failed\n");
goto fail6;
}
/* attach module instance 2 to the shared heap */
if (!wasm_runtime_attach_shared_heap(wasm_module_inst, shared_heap)) {
printf("Attach shared heap failed.\n");
goto fail6;
}
}
#endif
ret = 0;
const char *exception = NULL;
if (is_repl_mode) {
@ -1084,9 +1050,6 @@ main(int argc, char *argv[])
}
#endif
#if WASM_ENABLE_SHARED_HEAP != 0
fail6:
#endif
#if WASM_ENABLE_THREAD_MGR != 0
fail5:
#endif

View File

@ -27,16 +27,15 @@ ARG ZEPHYR_SDK_VERSION=0.16.9
# In west_lite.yml, the Zephyr version is set to v3.7.0
#ARG ZEPHYR_VERSION=3.7.0
# Install the Zephyr Software Development Kit (SDK) minimal version
# Install the Zephyr Software Development Kit (SDK)
WORKDIR /root/zephyrproject/zephyr-sdk
# hadolint ignore=DL4006
RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz \
RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz \
&& wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/sha256.sum | shasum --check --ignore-missing \
&& tar --strip-components=1 -xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz
&& tar --strip-components=1 -xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz
# hadolint ignore=DL4006
# Install arc tools, host tools and Register Zephyr SDK CMake package
# If you want to use other toolchains, please change the -t option
RUN ./setup.sh -t arc-zephyr-elf -h -c
# Install host tools and Register Zephyr SDK CMake package
RUN ./setup.sh -h -c
# Install west
# hadolint ignore=DL3013,DL3059

View File

@ -11,7 +11,6 @@ import subprocess
import glob
import re
import argparse
import sys
from typing import Dict, Optional, List
@ -276,11 +275,6 @@ def process_and_run_test_cases(
else:
print(f" Issues not found in folder: {format_issue_ids_should_test}")
if failed > 0:
# Exit with error code if there are failed test for CI
print("Some tests failed, see log file for details.")
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Run BA issue tests.")

View File

@ -3,17 +3,5 @@
# Copyright (C) 2020 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
TEMP_DIR=$(mktemp -d)
cleanup() {
local exit_code=$?
rm -rf "$TEMP_DIR"
exit $exit_code
}
trap cleanup EXIT INT TERM
/usr/bin/env python3 -m venv --clear "$TEMP_DIR"
source "$TEMP_DIR/bin/activate"
/usr/bin/env python3 -m pip install -r ../build-scripts/requirements.txt
/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
/usr/bin/env python3 ../build-scripts/build_llvm.py "$@"

View File

@ -3,5 +3,5 @@
# Copyright (C) 2020 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
$SCRIPT_DIR/build_llvm.sh --platform arc "$@"
/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
/usr/bin/env python3 ../build-scripts/build_llvm.py --platform arc "$@"

View File

@ -3,5 +3,5 @@
# Copyright (C) 2020 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
$SCRIPT_DIR/build_llvm.sh --platform xtensa "$@"
/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
/usr/bin/env python3 ../build-scripts/build_llvm.py --platform xtensa "$@"