Skip to content

Commit 27822aa

Browse files
committed
- Ignore Overlap errors from libtorch_cpu in valgrind.
- In TF: verify that model inputs names correspond to model inputs ops (and not just for any op)
1 parent 49f0605 commit 27822aa

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

opt/redis_valgrind.sup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
obj:*/libtorch.so.*
2727
}
2828

29+
{
30+
ignore_unversioned_libs
31+
Memcheck:Overlap
32+
...
33+
obj:*/libtorch_cpu.so*
34+
}
35+
2936
{
3037
ignore_unversioned_libs
3138
Memcheck:Leak

src/DAG/dag.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void Dag_LoadInputsToModelRunCtx(RedisAI_RunInfo *rinfo, RAI_DagOp *curre
6565
RAI_ContextUnlock(rinfo);
6666
return;
6767
}
68-
inputTensors[i] = inputTensor;
68+
inputTensors[i] = RAI_TensorGetShallowCopy(inputTensor);
6969
}
7070

7171
RAI_ContextUnlock(rinfo);
@@ -151,6 +151,7 @@ static void _DAG_PersistTensors(RedisModuleCtx *ctx, RedisAI_RunInfo *rinfo) {
151151
persist_entry = AI_dictNext(persist_iter);
152152
continue;
153153
}
154+
tensor = RAI_TensorGetShallowCopy(tensor);
154155
if (_StoreTensorInKeySpace(ctx, tensor, persist_key_name, true) == REDISMODULE_ERR) {
155156
*rinfo->dagError = 1;
156157
RedisModule_Log(ctx, "warning",

src/backends/tensorflow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ RAI_Model *RAI_ModelCreateTF(RAI_Backend backend, const char *devicestr, RAI_Mod
247247

248248
for (size_t i = 0; i < ninputs; ++i) {
249249
TF_Operation *oper = TF_GraphOperationByName(model, inputs[i]);
250-
if (oper == NULL) {
250+
if (oper == NULL || strcmp(TF_OperationOpType(oper), "Placeholder") != 0) {
251251
size_t len = strlen(inputs[i]);
252252
char *msg = RedisModule_Calloc(60 + len, sizeof(*msg));
253253
sprintf(msg, "ERR Input node named \"%s\" not found in TF graph.", inputs[i]);

tests/flow/tests.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ valgrind_config() {
7272

7373
RLTEST_ARGS+="\
7474
--use-valgrind \
75-
--vg-no-fail-on-errors \
7675
--vg-suppressions $VALGRIND_SUPRESSIONS"
7776
}
7877

tests/flow/tests_llapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def ensure_test_module_loaded(f):
1313
@wraps(f)
1414
def wrapper(env, *args, **kwargs):
15-
goal_dir = os.path.join(os.getcwd(), "../module/LLAPI.so")
15+
goal_dir = os.path.join(os.path.dirname(__file__), "../module/LLAPI.so")
1616
TEST_MODULE_PATH = os.path.abspath(goal_dir)
1717
con = env.getConnection()
1818
modules = con.execute_command("MODULE", "LIST")

tests/flow/tests_tensorflow.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ def test_run_tf_model_errors(env):
332332

333333
try:
334334
con.execute_command('AI.MODELGET')
335+
env.assertFalse(True)
335336
except Exception as e:
336337
exception = e
337338
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -342,6 +343,7 @@ def test_run_tf_model_errors(env):
342343
con.execute_command('SET', 'NOT_MODEL{1}', 'BAR')
343344
try:
344345
con.execute_command('AI.MODELGET', 'NOT_MODEL{1}')
346+
env.assertFalse(True)
345347
except Exception as e:
346348
exception = e
347349
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -354,6 +356,7 @@ def test_run_tf_model_errors(env):
354356
con.execute_command('DEL', 'DONT_EXIST{1}')
355357
try:
356358
con.execute_command('AI.MODELGET', 'DONT_EXIST{1}')
359+
env.assertFalse(True)
357360
except Exception as e:
358361
exception = e
359362
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -362,6 +365,7 @@ def test_run_tf_model_errors(env):
362365
try:
363366
ret = con.execute_command('AI.MODELSET', 'm{1}', 'TF', DEVICE,
364367
'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', 'BLOB', wrong_model_pb)
368+
env.assertFalse(True)
365369
except Exception as e:
366370
exception = e
367371
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -370,6 +374,7 @@ def test_run_tf_model_errors(env):
370374
try:
371375
con.execute_command('AI.MODELSET', 'm_1{1}', 'TF',
372376
'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', 'BLOB', model_pb)
377+
env.assertFalse(True)
373378
except Exception as e:
374379
exception = e
375380
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -378,6 +383,7 @@ def test_run_tf_model_errors(env):
378383
try:
379384
con.execute_command('AI.MODELSET', 'm_2{1}', 'PORCH', DEVICE,
380385
'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', 'BLOB', model_pb)
386+
env.assertFalse(True)
381387
except Exception as e:
382388
exception = e
383389
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -386,36 +392,41 @@ def test_run_tf_model_errors(env):
386392
try:
387393
con.execute_command('AI.MODELSET', 'm_3{1}', 'TORCH', DEVICE,
388394
'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', 'BLOB', model_pb)
395+
env.assertFalse(True)
389396
except Exception as e:
390397
exception = e
391398
env.assertEqual(type(exception), redis.exceptions.ResponseError)
392399

393400
try:
394401
con.execute_command('AI.MODELSET', 'm_4{1}', 'TF',
395402
'INPUTS', 'a', 'b', 'OUTPUTS', 'mul', 'BLOB', model_pb)
403+
env.assertFalse(True)
396404
except Exception as e:
397405
exception = e
398406
env.assertEqual(type(exception), redis.exceptions.ResponseError)
399407
env.assertEqual("Invalid DEVICE", exception.__str__())
400408

401409
try:
402410
con.execute_command('AI.MODELSET', 'm_5{1}', 'TF', DEVICE,
403-
'INPUTS', 'a', 'b', 'c', 'OUTPUTS', 'mul', 'BLOB', model_pb)
411+
'INPUTS', 'a', 'b', 'bad_input', 'OUTPUTS', 'mul', 'BLOB', model_pb)
412+
env.assertFalse(True)
404413
except Exception as e:
405414
exception = e
406415
env.assertEqual(type(exception), redis.exceptions.ResponseError)
407-
env.assertEqual("WRONGTYPE Operation against a key holding the wrong kind of value", exception.__str__())
416+
env.assertEqual("Input node named \"bad_input\" not found in TF graph.", exception.__str__())
408417

409418
try:
410419
con.execute_command('AI.MODELSET', 'm_6{1}', 'TF', DEVICE,
411420
'INPUTS', 'a', 'b', 'OUTPUTS', 'mult', 'BLOB', model_pb)
421+
env.assertFalse(True)
412422
except Exception as e:
413423
exception = e
414424
env.assertEqual(type(exception), redis.exceptions.ResponseError)
415425
env.assertEqual("Output node named \"mult\" not found in TF graph", exception.__str__())
416426

417427
try:
418428
con.execute_command('AI.MODELSET', 'm_7{1}', 'TF', DEVICE, 'BLOB', model_pb)
429+
env.assertFalse(True)
419430
except Exception as e:
420431
exception = e
421432
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -424,6 +435,7 @@ def test_run_tf_model_errors(env):
424435
try:
425436
con.execute_command('AI.MODELSET', 'm_8{1}', 'TF', DEVICE,
426437
'INPUTS', 'a', 'b', 'OUTPUTS', 'mul')
438+
env.assertFalse(True)
427439
except Exception as e:
428440
exception = e
429441
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -432,6 +444,7 @@ def test_run_tf_model_errors(env):
432444
try:
433445
con.execute_command('AI.MODELSET', 'm_8{1}', 'TF', DEVICE,
434446
'INPUTS', 'a_', 'b', 'OUTPUTS', 'mul')
447+
env.assertFalse(True)
435448
except Exception as e:
436449
exception = e
437450
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -440,6 +453,7 @@ def test_run_tf_model_errors(env):
440453
try:
441454
con.execute_command('AI.MODELSET', 'm_8{1}', 'TF', DEVICE,
442455
'INPUTS', 'a{1}', 'b{1}', 'OUTPUTS', 'mul_')
456+
env.assertFalse(True)
443457
except Exception as e:
444458
exception = e
445459
env.assertEqual(type(exception), redis.exceptions.ResponseError)
@@ -448,20 +462,23 @@ def test_run_tf_model_errors(env):
448462
try:
449463
con.execute_command('AI.MODELSET', 'm_8{1}', 'TF', DEVICE,
450464
'INPUTS', 'a', 'b', 'OUTPUTS')
465+
env.assertFalse(True)
451466
except Exception as e:
452467
exception = e
453468
env.assertEqual(type(exception), redis.exceptions.ResponseError)
454469
env.assertEqual("Insufficient arguments, missing model BLOB",exception.__str__())
455470

456471
try:
457472
con.execute_command('AI.MODELRUN', 'm{1}', 'INPUTS', 'a{1}', 'b{1}', 'OUTPUTS')
473+
env.assertFalse(True)
458474
except Exception as e:
459475
exception = e
460476
env.assertEqual(type(exception), redis.exceptions.ResponseError)
461477
env.assertEqual("Number of keys given as OUTPUTS here does not match model definition", exception.__str__())
462478

463479
try:
464480
con.execute_command('AI.MODELRUN', 'm{1}', 'OUTPUTS', 'c{1}', 'd{1}', 'e{1}')
481+
env.assertFalse(True)
465482
except Exception as e:
466483
exception = e
467484
env.assertEqual(type(exception), redis.exceptions.ResponseError)

0 commit comments

Comments
 (0)