Skip to content

Commit e480596

Browse files
committed
Create new test module that uses the LLAPI. Added a new flow test that loads this module and tests the LLAPI (currently contains a basic check only)
1 parent 78c77cf commit e480596

File tree

12 files changed

+685
-446
lines changed

12 files changed

+685
-446
lines changed

src/background_workers.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void *RedisAI_Run_ThreadMain(void *arg) {
178178
RedisAI_RunInfo *orig = rinfo->orig_copy;
179179
long long dagRefCount = RAI_DagRunInfoFreeShallowCopy(rinfo);
180180
if (dagRefCount == 0) {
181-
RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo *)orig;
181+
RedisAI_OnFinishCtx *finish_ctx = orig;
182182
orig->OnFinish(finish_ctx, orig->private_data);
183183
}
184184

@@ -417,7 +417,7 @@ void *RedisAI_Run_ThreadMain(void *arg) {
417417
RedisAI_RunInfo *orig = rinfo->orig_copy;
418418
long long dagRefCount = RAI_DagRunInfoFreeShallowCopy(rinfo);
419419
if (dagRefCount == 0) {
420-
RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo *)orig;
420+
RedisAI_OnFinishCtx *finish_ctx = orig;
421421
orig->OnFinish(finish_ctx, orig->private_data);
422422
}
423423
} else {
@@ -449,7 +449,7 @@ void *RedisAI_Run_ThreadMain(void *arg) {
449449
// If the reference count for the DAG is zero and the client is still around,
450450
// then we actually unblock the client
451451
if (dagRefCount == 0) {
452-
RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo *)orig;
452+
RedisAI_OnFinishCtx *finish_ctx = orig;
453453
orig->OnFinish(finish_ctx, orig->private_data);
454454
}
455455
}

src/dag.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "model.h"
3636
#include "redisai.h"
37+
#include "background_workers.h"
3738
#include "rmutil/alloc.h"
3839
#include "rmutil/args.h"
3940
#include "run_info.h"
@@ -889,7 +890,7 @@ void RedisAI_Disconnected(RedisModuleCtx *ctx, RedisModuleBlockedClient *bc) {
889890
RedisModule_Log(ctx, "warning", "Blocked client %p disconnected!", (void *)bc);
890891
}
891892

892-
// Parse the DAG run command and return true if it is a valid command to execute.
893+
// Parse the DAG run command and return REDISMODULE_OK only if it is a valid command to execute.
893894
static int DAG_CommandParser(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int dagMode,
894895
RedisAI_RunInfo **rinfo_ptr) {
895896

@@ -1229,7 +1230,7 @@ static int DAG_CommandParser(RedisModuleCtx *ctx, RedisModuleString **argv, int
12291230

12301231
// Add Shallow copies of the DAG run info to the devices' queues.
12311232
// Return REDISMODULE_OK in case of success, REDISMODULE_ERR if (at least) one insert op had failed.
1232-
static bool DAG_InsertDAGToQueue(RedisAI_RunInfo *rinfo) {
1233+
static int DAG_InsertDAGToQueue(RedisAI_RunInfo *rinfo) {
12331234
const char **devices = array_new(const char *, 10);
12341235

12351236
for (long long i = 0; i < array_len(rinfo->dagOps); i++) {
@@ -1280,7 +1281,7 @@ static bool DAG_InsertDAGToQueue(RedisAI_RunInfo *rinfo) {
12801281
array_free(rinfo_copies);
12811282
array_free(run_queues_info);
12821283
RAI_SetError(rinfo->err, RAI_EDAGRUN, "ERR Queue not initialized for device");
1283-
rinfo->OnFinish((RedisAI_OnFinishCtx)rinfo, rinfo->private_data);
1284+
rinfo->OnFinish((RedisAI_OnFinishCtx *)rinfo, rinfo->private_data);
12841285
return REDISMODULE_ERR;
12851286
}
12861287
run_queues_info = array_append(run_queues_info, run_queue_info);
@@ -1302,7 +1303,7 @@ static bool DAG_InsertDAGToQueue(RedisAI_RunInfo *rinfo) {
13021303
return REDISMODULE_OK;
13031304
}
13041305

1305-
void DAG_ReplyAndUnblock(RedisAI_OnFinishCtx ctx, void *private_data) {
1306+
void DAG_ReplyAndUnblock(RedisAI_OnFinishCtx *ctx, void *private_data) {
13061307

13071308
RedisAI_RunInfo *rinfo = (RedisAI_RunInfo *)ctx;
13081309
if (rinfo->client)

src/dag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,6 @@ int RedisAI_ProcessDagRunCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
175175
* @param ctx Context object that contains errors and results
176176
* @param private_data is a pointer to the DAG run info struct
177177
*/
178-
void DAG_ReplyAndUnblock(RedisAI_OnFinishCtx ctx, void *private_data);
178+
void DAG_ReplyAndUnblock(RedisAI_OnFinishCtx *ctx, void *private_data);
179179

180180
#endif /* SRC_DAG_H_ */

src/model.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include "model.h"
11+
#include "version.h"
1112
#include "backends.h"
1213
#include "backends/util.h"
1314
#include "model_struct.h"

src/redisai.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#ifndef SRC_REDISAI_H_
22
#define SRC_REDISAI_H_
33

4-
#include "background_workers.h"
5-
#include "model_struct.h"
6-
#include "redismodule.h"
7-
#include "util/dict.h"
8-
#include "version.h"
94
#include <stdbool.h>
5+
#include "redismodule.h"
106

11-
#define MODULE_API_FUNC(x) (*x)
7+
#define REDISAI_LLAPI_VERSION 1
8+
#define MODULE_API_FUNC(x) (*x)
129

1310
#ifndef REDISAI_H_INCLUDE
1411
typedef struct RAI_Tensor RAI_Tensor;
@@ -18,6 +15,8 @@ typedef struct RAI_Script RAI_Script;
1815
typedef struct RAI_ModelRunCtx RAI_ModelRunCtx;
1916
typedef struct RAI_ScriptRunCtx RAI_ScriptRunCtx;
2017
typedef struct RAI_Error RAI_Error;
18+
typedef struct RAI_ModelOpts RAI_ModelOpts;
19+
typedef struct RAI_OnFinishCtx RAI_OnFinishCtx;
2120
#endif
2221

2322
#define REDISAI_BACKEND_TENSORFLOW 0

0 commit comments

Comments
 (0)