Skip to content

Commit

Permalink
Merge pull request #10 from ucb-bar/install
Browse files Browse the repository at this point in the history
REFACTOR: change import directory structure to better help library installation
  • Loading branch information
T-K-233 authored Jul 20, 2024
2 parents 6dfb30d + a755bf6 commit 8dde10e
Show file tree
Hide file tree
Showing 76 changed files with 346 additions and 324 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ target_compile_features(target-riscv INTERFACE c_std_11)
target_compile_definitions(target-riscv INTERFACE RISCV)

set(WRAP_SPECS_FILE "htif_wrap.specs")
set(SPECS_FILE "nano.specs")
set(SPEC_FLAGS "-specs=${SPECS_FILE} -specs=${WRAP_SPECS_FILE}")
set(SPECS_FILE "htif_nano.specs")
set(SPEC_FLAGS -specs=${SPECS_FILE} -specs=${WRAP_SPECS_FILE})

set(MARCH "rv64gcv_zfh_zvfh_zvfhmin")
set(MABI "lp64d")
Expand Down
1 change: 1 addition & 0 deletions examples/fast-depth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ endif ()
target_compile_options(fast-depth PRIVATE -O3 -Wall -Wextra)

target_link_libraries(fast-depth PUBLIC nn)
target_link_libraries(fast-depth PUBLIC m)
1 change: 0 additions & 1 deletion examples/fast-depth/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define __MODEL_H

#include "nn.h"
#include "nn_relu.h"


// load the weight data block from the model.bin file
Expand Down
1 change: 1 addition & 0 deletions examples/llama2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ endif ()
target_compile_options(llama2 PRIVATE -O3 -Wall -Wextra)

target_link_libraries(llama2 PUBLIC nn)
target_link_libraries(llama2 PUBLIC m)

10 changes: 2 additions & 8 deletions nn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

cmake_minimum_required(VERSION 3.10)

set(cpu_impl
./impl/cpu/abs.c
Expand Down Expand Up @@ -112,10 +112,7 @@ add_library(nn
${cpu_impl}
)

target_include_directories(nn PUBLIC
./
./functional
./impl)
target_include_directories(nn PUBLIC ./)

if (X86)
message(STATUS "nn: Building for x86")
Expand All @@ -128,6 +125,3 @@ endif ()


target_link_libraries(nn m)



2 changes: 1 addition & 1 deletion nn/functional/nn_abs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "abs.h"
#include "impl/abs.h"


/**
Expand Down
8 changes: 4 additions & 4 deletions nn/functional/nn_add.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#include "nn_tensor.h"
#include "nn_print.h"
#include "acc.h"
#include "acc1.h"
#include "add.h"
#include "add1.h"
#include "impl/acc.h"
#include "impl/acc1.h"
#include "impl/add.h"
#include "impl/add1.h"


/**
Expand Down
4 changes: 2 additions & 2 deletions nn/functional/nn_clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <assert.h>

#include "nn_tensor.h"
#include "maximum1.h"
#include "minimum1.h"
#include "impl/maximum1.h"
#include "impl/minimum1.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_div.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <float.h>

#include "nn_tensor.h"
#include "div.h"
#include "impl/div.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_fill.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <math.h>

#include "nn_tensor.h"
#include "fill.h"
#include "impl/fill.h"

/**
* Fills the tensor with the specified value.
Expand Down
12 changes: 6 additions & 6 deletions nn/functional/nn_layer_norm.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include <math.h>

#include "nn_tensor.h"
#include "sum.h"
#include "add.h"
#include "add1.h"
#include "mul.h"
#include "mul1.h"
#include "sqr.h"
#include "impl/sum.h"
#include "impl/add.h"
#include "impl/add1.h"
#include "impl/mul.h"
#include "impl/mul1.h"
#include "impl/sqr.h"


void NN_layer_norm(
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_max.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <float.h>

#include "nn_tensor.h"
#include "max.h"
#include "impl/max.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_maximum.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "maximum.h"
#include "impl/maximum.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_min.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <float.h>

#include "nn_tensor.h"
#include "min.h"
#include "impl/min.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_minimum.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "minimum.h"
#include "impl/minimum.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "dot.h"
#include "impl/dot.h"


/**
Expand Down
4 changes: 2 additions & 2 deletions nn/functional/nn_mul.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <float.h>

#include "nn_tensor.h"
#include "mul.h"
#include "mul1.h"
#include "impl/mul.h"
#include "impl/mul1.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_mv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "dot.h"
#include "impl/dot.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_neg.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "neg.h"
#include "impl/neg.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_relu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "maximum1.h"
#include "impl/maximum1.h"


/**
Expand Down
4 changes: 2 additions & 2 deletions nn/functional/nn_relu6.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <assert.h>

#include "nn_tensor.h"
#include "maximum1.h"
#include "minimum1.h"
#include "impl/maximum1.h"
#include "impl/minimum1.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_rms_norm.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <math.h>

#include "nn_tensor.h"
#include "rms_norm.h"
#include "impl/rms_norm.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_silu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <math.h>

#include "nn_tensor.h"
#include "maximum1.h"
#include "impl/maximum1.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_softmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "softmax.h"
#include "impl/softmax.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_sub.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "nn_tensor.h"
#include "nn_print.h"
#include "sub.h"
#include "impl/sub.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "sum.h"
#include "impl/sum.h"


/**
Expand Down
2 changes: 1 addition & 1 deletion nn/functional/nn_transpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <assert.h>

#include "nn_tensor.h"
#include "transpose.h"
#include "impl/transpose.h"

/**
* Transpose a 2D tensor
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/abs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "abs.h"
#include "impl/abs.h"


__attribute__((weak)) void NN__abs_i8(size_t n, int8_t *y, size_t incy, const int8_t *x, size_t incx) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/acc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "acc.h"
#include "impl/acc.h"


__attribute__((weak)) void NN__acc_i8(size_t n, int8_t *y, size_t incy, const int8_t *x, size_t incx) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/acc1.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "acc1.h"
#include "impl/acc1.h"


__attribute__((weak)) void NN__acc1_i8(size_t n, int8_t *result, size_t incr, int8_t scalar) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/add.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "add.h"
#include "impl/add.h"


__attribute__((weak)) void NN__add_i8(size_t n, int8_t *z, size_t incz, const int8_t *x, size_t incx, const int8_t *y, size_t incy) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/add1.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "add1.h"
#include "impl/add1.h"



Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/div.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "div.h"
#include "impl/div.h"


__attribute__((weak)) void NN__div_i8(size_t n, int8_t *z, size_t incz, const int8_t *x, size_t incx, const int8_t *y, size_t incy) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/dot.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "dot.h"
#include "impl/dot.h"


__attribute__((weak)) void NN__dot_i8_to_i32(size_t n, int32_t *result, const int8_t *x, size_t incx, const int8_t *y, size_t incy) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/fill.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "fill.h"
#include "impl/fill.h"


__attribute__((weak)) void NN__fill_u8(size_t n, uint8_t *x, size_t incx, uint8_t scalar) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/log.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "log.h"
#include "impl/log.h"


__attribute__((weak)) void NN__log_f32(size_t n, float *y, size_t incy, const float *x, size_t incx) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/max.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "max.h"
#include "impl/max.h"


__attribute__((weak)) void NN__max_i8(size_t n, int8_t *result, const int8_t *x, size_t incx) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/maximum.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "maximum.h"
#include "impl/maximum.h"


__attribute__((weak)) void NN__maximum_i8(size_t n, int8_t *z, size_t incz, const int8_t *x, size_t incx, const int8_t *y, size_t incy) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/maximum1.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "maximum1.h"
#include "impl/maximum1.h"


__attribute__((weak)) void NN__maximum1_i8(size_t n, int8_t *y, size_t incy, const int8_t *x, size_t incx, int8_t scalar) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/min.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "min.h"
#include "impl/min.h"


__attribute__((weak)) void NN__min_i8(size_t n, int8_t *result, const int8_t *x, size_t incx) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/minimum.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "minimum.h"
#include "impl/minimum.h"


__attribute__((weak)) void NN__minimum_i8(size_t n, int8_t *z, size_t incz, const int8_t *x, size_t incx, const int8_t *y, size_t incy) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/minimum1.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "minimum1.h"
#include "impl/minimum1.h"


__attribute__((weak)) void NN__minimum1_i8(size_t n, int8_t *y, size_t incy, const int8_t *x, size_t incx, int8_t scalar) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/mul.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "mul.h"
#include "impl/mul.h"


__attribute__((weak)) void NN__mul_i8(size_t n, int8_t *z, size_t incz, const int8_t *x, size_t incx, const int8_t *y, size_t incy) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/mul1.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "mul1.h"
#include "impl/mul1.h"


__attribute__((weak)) void NN__mul1_i8(size_t n, int8_t *y, size_t incy, const int8_t *x, size_t incx, int8_t scalar) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/neg.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "neg.h"
#include "impl/neg.h"


__attribute__((weak)) void NN__neg_i8(size_t n, int8_t *y, size_t incy, const int8_t *x, size_t incx) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/norm.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "norm.h"
#include "impl/norm.h"


__attribute__((weak)) void NN__norm_f32(size_t n, float *result, const float *x, size_t incx) {
Expand Down
2 changes: 1 addition & 1 deletion nn/impl/cpu/rms_norm.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "rms_norm.h"
#include "impl/rms_norm.h"


__attribute__((weak)) void NN__rms_norm_f32(size_t n, float* y, size_t incy, const float* x, size_t incx, const float* w, size_t incw, float eps) {
Expand Down
Loading

0 comments on commit 8dde10e

Please sign in to comment.