@@ -17,6 +17,8 @@ int ValidatePersistKeys(RedisAI_RunInfo *rinfo, AI_dict *tensorsNamesToInd,
1717 AI_dictReleaseIterator (iter );
1818 return REDISMODULE_ERR ;
1919 }
20+ size_t index = (size_t )AI_dictGetVal (entry );
21+ AI_dictReplace (persistTensorsNames , (void * )persist_key , (void * )index );
2022 }
2123 AI_dictReleaseIterator (iter );
2224 }
@@ -35,29 +37,23 @@ int MapTensorsKeysToIndices(RedisAI_RunInfo *rinfo, AI_dict *tensorsNamesToInd)
3537 RAI_SetError (rinfo -> err , RAI_EDAGRUN , "ERR INPUT key cannot be found in DAG" );
3638 return REDISMODULE_ERR ;
3739 }
38- int * ind = AI_dictGetVal (entry );
39- currentOp -> inkeys_indices = array_append (currentOp -> inkeys_indices , * ind );
40+ size_t ind = ( size_t ) AI_dictGetVal (entry );
41+ currentOp -> inkeys_indices = array_append (currentOp -> inkeys_indices , ind );
4042 }
4143
4244 for (long long j = 0 ; j < array_len (currentOp -> outkeys ); j ++ ) {
4345 RedisModuleString * key = currentOp -> outkeys [j ];
44- int * ind = RedisModule_Alloc (sizeof (int ));
45- * ind = array_len (rinfo -> dagSharedTensors );
46+ size_t ind = array_len (rinfo -> dagSharedTensors );
4647
4748 // Add a new empty place holder in the array for an output tensor.
48- // If this is MODELSET op, the tensor is already realized.
49+ // If this is a TENSORSET op, the tensor is already realized.
4950 if (currentOp -> commandType == REDISAI_DAG_CMD_TENSORSET ) {
5051 RAI_Tensor * t = RAI_TensorGetShallowCopy (currentOp -> outTensor );
5152 rinfo -> dagSharedTensors = array_append (rinfo -> dagSharedTensors , t );
5253 } else {
5354 rinfo -> dagSharedTensors = array_append (rinfo -> dagSharedTensors , NULL );
5455 }
55- currentOp -> outkeys_indices = array_append (currentOp -> outkeys_indices , * ind );
56- AI_dictEntry * entry = AI_dictFind (tensorsNamesToInd , (void * )key );
57- // If this key was already in the dict, remove and free the previous index
58- if (entry ) {
59- RedisModule_Free (AI_dictGetVal (entry ));
60- }
56+ currentOp -> outkeys_indices = array_append (currentOp -> outkeys_indices , ind );
6157 AI_dictReplace (tensorsNamesToInd , (void * )key , (void * )ind );
6258 }
6359 }
0 commit comments