Skip to content

Commit

Permalink
Merge branch 'master' into release/2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyang2057 committed Jul 30, 2024
2 parents 5c01db9 + 0e8dabd commit 5511209
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ jobs:

- name: Install Python Packages
run:
python -m pip install --upgrade pip
# python -m pip install --upgrade "pip<24.0" #pip24 not available on 3.7
pip install -r requirements.test.txt

- name: Create Test Environment
Expand Down
6 changes: 3 additions & 3 deletions src/Native/src/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ else()
if(os_name STREQUAL "linux")
target_link_libraries(kernels PRIVATE -lpthread)
endif()
target_compile_definitions(kernels PRIVATE "-DNNCASE_HALIDE")
target_compile_definitions(kernels PRIVATE "-DNNCASE_HALIDE")
endif()

target_compile_definitions(kernels PUBLIC -DNNCASE_DLL -DNNCASE_SIMULATOR)
set_property(TARGET kernels PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
Expand All @@ -38,7 +38,7 @@ if(ENABLE_OPENMP)
endif()

if(APPLE)
target_compile_options(kernels PRIVATE -Wno-gnu-zero-variadic-macro-arguments)
target_compile_options(kernels PRIVATE -Wno-gnu-zero-variadic-macro-arguments)
endif(APPLE)


Expand Down
2 changes: 1 addition & 1 deletion src/Native/src/kernels/stackvm/optimized/concat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ result<void> concat_impl(gsl::span<const gsl::byte *const> inputs, T *output,
out_ptr = output + offset(out_strides, out_index);
const auto *in_ptr = reinterpret_cast<const T *>(inputs[n]) +
offset(in_strides[n], in_index);
memcpy(out_ptr, in_ptr, width * sizeof(T));
opt_memcpy(out_ptr, in_ptr, width * sizeof(T));
};

auto concat_last_dim = [&](size_t dim) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
cmake_minimum_required (VERSION 3.13)
8 changes: 4 additions & 4 deletions src/Native/src/kernels/stackvm/optimized/riscv64/binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static int verify_shape_impl(gsl::span<const size_t> in_a_shape,

if (in_b_shape[in_b_shape.size() - 1] == 1) {
int len_b_leave = 1;
for (int i = index + 1; i < in_b_shape.size(); ++i) {
for (int i = index + 1; i < (int)in_b_shape.size(); ++i) {
len_b_leave *= in_b_shape[i];
}
if (len_b_leave != 1) {
Expand Down Expand Up @@ -392,7 +392,7 @@ static int verify_shape(gsl::span<const size_t> in_a_shape,
static gsl::span<const size_t>
get_sample_span(gsl::span<const size_t> in_shape) {
int not_one_index = 0;
for (int i = 0; i < in_shape.size(); ++i) {
for (int i = 0; i < (int)in_shape.size(); ++i) {
if (in_shape[i] != 1) {
not_one_index = i;
break;
Expand Down Expand Up @@ -439,7 +439,7 @@ get_sample_span(gsl::span<const size_t> in_shape) {
(index != (int)(in_b_shape.size() - 1))) { \
int size_diff = in_a_shape.size() - in_b_shape.size(); \
int len_a_leave = 1; \
for (int i = index + 1; i < in_b_shape.size(); ++i) { \
for (int i = index + 1; i < (int)in_b_shape.size(); ++i) { \
len_a_leave *= in_a_shape[i + size_diff]; \
} \
for (int j = 0; j < outter_front_size; ++j) { \
Expand Down Expand Up @@ -470,7 +470,7 @@ get_sample_span(gsl::span<const size_t> in_shape) {
(index != (int)(in_a_shape.size() - 1))) { \
int size_diff = in_b_shape.size() - in_a_shape.size(); \
int len_b_leave = 1; \
for (int i = index + 1; i < in_a_shape.size(); ++i) { \
for (int i = index + 1; i < (int)in_a_shape.size(); ++i) { \
len_b_leave *= in_b_shape[i + size_diff]; \
} \
for (int j = 0; j < outter_front_size; ++j) { \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static int get_parameter(gsl::span<const size_t> in_shape,
}
int _sum1 = (max_index + min_index) * (max_index - min_index + 1) >> 1;
int _sum2 = axis[0];
for (int i = 1; i < axis.size(); ++i) {
for (int i = 1; i < (int)axis.size(); ++i) {
_sum2 += axis[i];
}
if (_sum2 != _sum1) {
Expand Down
9 changes: 9 additions & 0 deletions src/Native/src/runtime/stackvm/op_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@

#ifdef NNCASE_BAREMETAL
double get_ms_time();
#elif defined(LINUX_RUNTIME)
#include <chrono>
double get_ms_time() {
auto now = std::chrono::high_resolution_clock::now();
auto duration =
std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(
now.time_since_epoch());
return duration.count();
}
#else
double get_ms_time() { return (double)clock() / 1000; }
#endif
Expand Down
10 changes: 6 additions & 4 deletions toolchains/k230.linux.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ if(NOT RISCV_ROOT_PATH)
endif()

set(RISCV_ROOT_PATH ${RISCV_ROOT_PATH} CACHE STRING "root path to riscv toolchain")
set(CMAKE_C_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-gcc")
set(CMAKE_CXX_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-g++")
set(CMAKE_FIND_ROOT_PATH "${RISCV_ROOT_PATH}/riscv64-unknown-linux-musl")
set(CMAKE_C_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-g++")
set(CMAKE_FIND_ROOT_PATH "${RISCV_ROOT_PATH}/riscv64-unknown-linux-gnu")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
Expand All @@ -29,4 +29,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=rv64imafdcv -mabi=lp64d -mcmodel=

set(BUILDING_RUNTIME ON)
set(ENABLE_K230_RUNTIME ON)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_SHARED_LIBS OFF)

add_definitions(-DLINUX_RUNTIME)
33 changes: 33 additions & 0 deletions toolchains/k230.rtos.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR riscv64)

if(DEFINED ENV{RISCV_ROOT_PATH})
file(TO_CMAKE_PATH $ENV{RISCV_ROOT_PATH} RISCV_ROOT_PATH)
endif()

if(NOT RISCV_ROOT_PATH)
message(FATAL_ERROR "RISCV_ROOT_PATH env must be defined for rtos runtime")
endif()

set(RISCV_ROOT_PATH ${RISCV_ROOT_PATH} CACHE STRING "root path to riscv toolchain")
set(CMAKE_C_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-gcc")
set(CMAKE_CXX_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-g++")
set(CMAKE_FIND_ROOT_PATH "${RISCV_ROOT_PATH}/riscv64-unknown-linux-musl")


set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(ENABLE_VULKAN_RUNTIME OFF)
set(ENABLE_OPENMP OFF)
set(ENABLE_HALIDE OFF)
set(DEFAULT_BUILTIN_RUNTIMES OFF)
set(DEFAULT_SHARED_RUNTIME_TENSOR_PLATFORM_IMPL OFF)
set(BUILD_BENCHMARK OFF)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=rv64imafdcv -mabi=lp64d -mcmodel=medany")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=rv64imafdcv -mabi=lp64d -mcmodel=medany")

set(BUILDING_RUNTIME ON)
set(ENABLE_K230_RUNTIME ON)
set(BUILD_SHARED_LIBS OFF)

0 comments on commit 5511209

Please sign in to comment.