Skip to content

Commit f418761

Browse files
author
DvirDukhan
committed
onnx info
1 parent 0e68fc1 commit f418761

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/backends.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,16 @@ int RAI_LoadBackend_ONNXRuntime(RedisModuleCtx *ctx, const char *path) {
417417
return REDISMODULE_ERR;
418418
}
419419

420+
backend.get_version = (const char*(*)(void))(unsigned long)dlsym(handle, "RAI_GetBackendVersionORT");
421+
if (backend.get_version == NULL) {
422+
dlclose(handle);
423+
RedisModule_Log(ctx, "warning",
424+
"Backend does not export RAI_GetBackendVersionORT. ONNX backend "
425+
"not loaded from %s",
426+
path);
427+
return REDISMODULE_ERR;
428+
}
429+
420430
RAI_backends.onnx = backend;
421431

422432
RedisModule_Log(ctx, "notice", "ONNX backend loaded from %s", path);

src/backends/onnxruntime.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,3 +670,8 @@ int RAI_ModelSerializeORT(RAI_Model *model, char **buffer, size_t *len, RAI_Erro
670670

671671
return 0;
672672
}
673+
674+
const char* RAI_GetBackendVersionORT(void) {
675+
return OrtGetApiBase()->GetVersionString();
676+
}
677+

src/backends/onnxruntime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ int RAI_ModelRunORT(RAI_ModelRunCtx **mctxs, RAI_Error *error);
1717

1818
int RAI_ModelSerializeORT(RAI_Model *model, char **buffer, size_t *len, RAI_Error *error);
1919

20+
const char* RAI_GetBackendVersionORT(void);
21+
2022
#endif /* SRC_BACKENDS_ONNXRUNTIME_H_ */

src/redisai.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,9 @@ void _RedisAI_Info(RedisModuleCtx* ctx) {
847847
RedisModule_ReplyWithSimpleString(ctx, RAI_backends.tf.get_version());
848848
}
849849

850-
if(RAI_backends.torch.get_version){
851-
RedisModule_ReplyWithSimpleString(ctx, "Torch version");
852-
RedisModule_ReplyWithSimpleString(ctx, RAI_backends.torch.get_version());
850+
if(RAI_backends.onnx.get_version){
851+
RedisModule_ReplyWithSimpleString(ctx, "ONNX version");
852+
RedisModule_ReplyWithSimpleString(ctx, RAI_backends.onnx.get_version());
853853
}
854854

855855

0 commit comments

Comments
 (0)