Skip to content

Folder structure refactor #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")

# Add -fno-omit-frame-pointer to avoid seeing incomplete stack traces
set(CMAKE_COMMON_FLAGS_DEBUG "-g -ggdb -fno-omit-frame-pointer -D_DEBUG -DVALGRIND -include \
${CMAKE_CURRENT_SOURCE_DIR}/src/common.h -I${CMAKE_CURRENT_SOURCE_DIR}/opt")
${CMAKE_CURRENT_SOURCE_DIR}/src/config/gdb_config.h -I${CMAKE_CURRENT_SOURCE_DIR}/opt")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_COMMON_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_COMMON_FLAGS_DEBUG}")

Expand Down Expand Up @@ -98,6 +98,7 @@ GET_FILENAME_COMPONENT(installAbs
#----------------------------------------------------------------------------------------------

INCLUDE_DIRECTORIES(${depsAbs}/dlpack/include)
INCLUDE_DIRECTORIES(src)
IF(BUILD_TF)
INCLUDE_DIRECTORIES(${depsAbs}/libtensorflow/include)
ENDIF()
Expand Down Expand Up @@ -182,7 +183,7 @@ IF(BUILD_TFLITE)
# Find TensorFlow Lite stuff and build our wrapper
INCLUDE_DIRECTORIES(util/libtflite_c)

ADD_SUBDIRECTORY(src/libtflite_c)
ADD_SUBDIRECTORY(src/backends/libtflite_c)
ENDIF()

#----------------------------------------------------------------------------------------------
Expand All @@ -194,7 +195,7 @@ IF(BUILD_TORCH)

INCLUDE_DIRECTORIES(util/libtorch_c)

ADD_SUBDIRECTORY(src/libtorch_c)
ADD_SUBDIRECTORY(src/backends/libtorch_c)
ENDIF()

#----------------------------------------------------------------------------------------------
Expand Down
46 changes: 22 additions & 24 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ if (CMAKE_BUILD_TYPE STREQUAL Debug)
endif()

file (GLOB_RECURSE SERIALIZATION_SRC
tensor.c
model.c
script.c
backends.c
redis_ai_objects/tensor.c
redis_ai_objects/model.c
redis_ai_objects/script.c
backends/backends.c
stats.c
config.c
serialization/*.c)

file (GLOB BACKEND_COMMON_SRC
backends/util.c
err.c
redis_ai_objects/err.c
util/dict.c
tensor.c
redis_ai_objects/tensor.c
util/string_utils.c
serialization/ai_datatypes.c)

Expand All @@ -24,28 +24,26 @@ ADD_LIBRARY(redisai_obj OBJECT
util/queue.c
util/string_utils.c
redisai.c
command_parser.c
run_info.c
background_workers.c
config.c
DAG/dag.c
DAG/dag_parser.c
DAG/dag_builder.c
DAG/dag_execute.c
modelRun_ctx.c
backends.c
execution/command_parser.c
execution/run_info.c
execution/background_workers.c
config/config.c
execution/DAG/dag.c
execution/DAG/dag_parser.c
execution/DAG/dag_builder.c
execution/DAG/dag_execute.c
execution/modelRun_ctx.c
backends/backends.c
backends/util.c
model.c
err.c
script.c
stats.c
tensor.c
redis_ai_objects/model.c
redis_ai_objects/err.c
redis_ai_objects/script.c
redis_ai_objects/stats.c
redis_ai_objects/tensor.c
rmutil/alloc.c
rmutil/sds.c
rmutil/args.c
rmutil/heap.c
rmutil/priority_queue.c
rmutil/vector.c run_info.c
execution/run_info.c
redis_ai_types/model_type.c
redis_ai_types/tensor_type.c
redis_ai_types/script_type.c
Expand Down
File renamed without changes.
15 changes: 6 additions & 9 deletions src/backends.h → src/backends/backends.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
*
*/

#ifndef SRC_BACKENDS_H_
#define SRC_BACKENDS_H_
#pragma once

#include "config.h"
#include "err.h"
#include "model_struct.h"
#include "script_struct.h"
#include "tensor.h"
#include "config/config.h"
#include "redis_ai_objects/err.h"
#include "redis_ai_objects/tensor.h"
#include "redis_ai_objects/model_struct.h"
#include "redis_ai_objects/script_struct.h"

/*
* To register a new backend to be loaded by the module, the backend needs to
Expand Down Expand Up @@ -98,5 +97,3 @@ int RAI_LoadBackend(RedisModuleCtx *ctx, int backend, const char *path);
int RAI_LoadDefaultBackend(RedisModuleCtx *ctx, int backend);

const char *RAI_BackendName(int backend);

#endif
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "tflite_c.h"
#include <iostream>
#include <sstream>
#include <iostream>
#include "tflite_c.h"
#include "redismodule.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/tools/evaluation/utils.h"
#include "../redismodule.h"

namespace {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __TFLITE_C_H__
#define __TFLITE_C_H__
#pragma once

#include "dlpack/dlpack.h"

Expand Down Expand Up @@ -30,5 +29,3 @@ const char *tfliteModelOutputNameAtIndex(void *modelCtx, size_t index, char **er
#ifdef __cplusplus
}
#endif

#endif // __TFLITE_C_H__
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "torch_c.h"
#include "torch/torch.h"
#include "redismodule.h"
#include "ATen/Functions.h"
#include "torch/csrc/jit/serialization/import.h"
#include "torch/csrc/jit/api/compilation_unit.h"
#include "ATen/Functions.h"
#include "../redismodule.h"

#include <iostream>
#include <sstream>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef __TORCH_C_H__
#define __TORCH_C_H__
#pragma once

#include "dlpack/dlpack.h"

Expand Down Expand Up @@ -43,5 +42,3 @@ size_t torchModelNumOutputs(void *modelCtx, char **error);
#ifdef __cplusplus
}
#endif

#endif // __TORCH_C_H__
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <string>
#include "torch_redis.h"
#include "../../redismodule.h"
#include "../../../redismodule.h"

torch::IValue IValueFromRedisReply(RedisModuleCallReply *reply){

Expand Down
6 changes: 3 additions & 3 deletions src/backends/onnxruntime.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#define REDISMODULE_MAIN
#include <cuda_provider_factory.h>
#include "backends/onnxruntime.h"
#include "backends/util.h"
#include "tensor.h"
#include "util/arr_rm_alloc.h"
#include <stdatomic.h>
#include "util/arr.h"
#include "backends/onnxruntime.h"
#include "redis_ai_objects/tensor.h"

#include "onnxruntime_c_api.h"

Expand Down
13 changes: 5 additions & 8 deletions src/backends/onnxruntime.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#ifndef SRC_BACKENDS_ONNXRUNTIME_H_
#define SRC_BACKENDS_ONNXRUNTIME_H_
#pragma once

#include "config.h"
#include "tensor_struct.h"
#include "model_struct.h"
#include "err.h"
#include "config/config.h"
#include "redis_ai_objects/err.h"
#include "redis_ai_objects/tensor_struct.h"
#include "redis_ai_objects/model_struct.h"

unsigned long long RAI_GetMemoryInfoORT(void);

Expand All @@ -22,5 +21,3 @@ int RAI_ModelRunORT(RAI_ModelRunCtx **mctxs, RAI_Error *error);
int RAI_ModelSerializeORT(RAI_Model *model, char **buffer, size_t *len, RAI_Error *error);

const char *RAI_GetBackendVersionORT(void);

#endif /* SRC_BACKENDS_ONNXRUNTIME_H_ */
8 changes: 4 additions & 4 deletions src/backends/tensorflow.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define REDISMODULE_MAIN
#include "backends/tensorflow.h"
#include "backends/util.h"
#include "tensor.h"
#include "util/arr_rm_alloc.h"
#include "model.h"
#include "backends/tensorflow.h"
#include "util/arr.h"
#include "redis_ai_objects/model.h"
#include "redis_ai_objects/tensor.h"

#include "tensorflow/c/c_api.h"

Expand Down
13 changes: 5 additions & 8 deletions src/backends/tensorflow.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#ifndef SRC_BACKENDS_TENSORFLOW_H_
#define SRC_BACKENDS_TENSORFLOW_H_
#pragma once

#include "config.h"
#include "tensor_struct.h"
#include "model_struct.h"
#include "err.h"
#include "config/config.h"
#include "redis_ai_objects/err.h"
#include "redis_ai_objects/tensor_struct.h"
#include "redis_ai_objects/model_struct.h"

int RAI_InitBackendTF(int (*get_api_fn)(const char *, void *));

Expand All @@ -20,5 +19,3 @@ int RAI_ModelRunTF(RAI_ModelRunCtx **mctxs, RAI_Error *error);
int RAI_ModelSerializeTF(RAI_Model *model, char **buffer, size_t *len, RAI_Error *error);

const char *RAI_GetBackendVersionTF(void);

#endif /* SRC_BACKENDS_TENSORFLOW_H_ */
6 changes: 3 additions & 3 deletions src/backends/tflite.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define REDISMODULE_MAIN
#include "backends/tflite.h"
#include "backends/util.h"
#include "tensor.h"
#include "util/arr_rm_alloc.h"
#include "backends/tflite.h"
#include "util/arr.h"
#include "libtflite_c/tflite_c.h"
#include "redis_ai_objects/tensor.h"

int RAI_InitBackendTFLite(int (*get_api_fn)(const char *, void *)) {
get_api_fn("RedisModule_Alloc", ((void **)&RedisModule_Alloc));
Expand Down
8 changes: 4 additions & 4 deletions src/backends/tflite.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "config.h"
#include "tensor_struct.h"
#include "model_struct.h"
#include "err.h"
#include "config/config.h"
#include "redis_ai_objects/err.h"
#include "redis_ai_objects/model_struct.h"
#include "redis_ai_objects/tensor_struct.h"

int RAI_InitBackendTFLite(int (*get_api_fn)(const char *, void *));

Expand Down
6 changes: 3 additions & 3 deletions src/backends/torch.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define REDISMODULE_MAIN
#include "backends/torch.h"
#include "backends/util.h"
#include "tensor.h"
#include "util/arr_rm_alloc.h"
#include "backends/torch.h"
#include "util/arr.h"
#include "libtorch_c/torch_c.h"
#include "redis_ai_objects/tensor.h"

int RAI_InitBackendTorch(int (*get_api_fn)(const char *, void *)) {
get_api_fn("RedisModule_Alloc", ((void **)&RedisModule_Alloc));
Expand Down
10 changes: 5 additions & 5 deletions src/backends/torch.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "config.h"
#include "tensor_struct.h"
#include "script_struct.h"
#include "model_struct.h"
#include "err.h"
#include "config/config.h"
#include "redis_ai_objects/err.h"
#include "redis_ai_objects/model_struct.h"
#include "redis_ai_objects/tensor_struct.h"
#include "redis_ai_objects/script_struct.h"

int RAI_InitBackendTorch(int (*get_api_fn)(const char *, void *));

Expand Down
7 changes: 2 additions & 5 deletions src/backends/util.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#ifndef SRC_BACKENDS_UTIL_H_
#define SRC_BACKENDS_UTIL_H_
#pragma once

#include <stdint.h>
#include <stdio.h>
#include <strings.h>

#include "config.h"
#include "config/config.h"

int parseDeviceStr(const char *devicestr, RAI_Device *device, int64_t *deviceid);

#endif /* SRC_BACKENDS_UTIL_H_ */
9 changes: 4 additions & 5 deletions src/config.c → src/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
#include <sys/time.h>
#include <unistd.h>

#include "backends.h"
#include "backends/util.h"
#include "background_workers.h"
#include "err.h"
#include "redismodule.h"
#include "rmutil/alloc.h"
#include "util/arr_rm_alloc.h"
#include "backends/util.h"
#include "backends/backends.h"
#include "util/dict.h"
#include "util/queue.h"
#include "util/arr.h"
#include "execution/background_workers.h"

long long backends_intra_op_parallelism; // number of threads used within an
// individual op for parallelism.
Expand Down
5 changes: 1 addition & 4 deletions src/config.h → src/config/config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef SRC_CONFIG_H_
#define SRC_CONFIG_H_
#pragma once

#include "redismodule.h"

Expand Down Expand Up @@ -159,5 +158,3 @@ int RAI_configParamParse(RedisModuleCtx *ctx, const char *key, const char *val,
* @return REDISMODULE_OK on success, or REDISMODULE_ERR if the DAGRUN failed
*/
int RAI_loadTimeConfig(RedisModuleCtx *ctx, RedisModuleString *const *argv, int argc);

#endif /* SRC_CONFIG_H_ */
File renamed without changes.
Loading