@@ -33,10 +33,10 @@ static void Graph_RdbSave(RedisModuleIO *rdb, void *value){
33
33
}
34
34
35
35
static void Graph_DTFree (void * value ){
36
- Graph_Free (value );
36
+ RDL_GraphFree (value );
37
37
}
38
38
39
- int Graph_Init (RedisModuleCtx * ctx ){
39
+ int RDL_GraphInit (RedisModuleCtx * ctx ){
40
40
RedisModuleTypeMethods tmGraph = {
41
41
.version = REDISMODULE_TYPE_METHOD_VERSION ,
42
42
.rdb_load = Graph_RdbLoad ,
@@ -51,7 +51,7 @@ int Graph_Init(RedisModuleCtx* ctx){
51
51
return RedisDL_GraphType != NULL ;
52
52
}
53
53
54
- RDL_Graph * Graph_Create (const char * prefix , const char * graphdef , size_t graphlen ){
54
+ RDL_Graph * RDL_GraphCreate (const char * prefix , const char * graphdef , size_t graphlen ){
55
55
TF_Graph * graph = TF_NewGraph ();
56
56
57
57
TF_ImportGraphDefOptions * options = TF_NewImportGraphDefOptions ();
@@ -95,7 +95,7 @@ RDL_Graph* Graph_Create(const char* prefix, const char* graphdef, size_t graphle
95
95
return ret ;
96
96
}
97
97
98
- void Graph_Free (RDL_Graph * graph ){
98
+ void RDL_GraphFree (RDL_Graph * graph ){
99
99
if (-- graph -> refCount > 0 ){
100
100
return ;
101
101
}
@@ -125,10 +125,10 @@ void Graph_Free(RDL_Graph* graph){
125
125
RedisModule_Free (graph );
126
126
}
127
127
128
- RDL_GraphRunCtx * Graph_RunCtxCreate (RDL_Graph * graph ){
128
+ RDL_GraphRunCtx * RDL_RunCtxCreate (RDL_Graph * graph ){
129
129
#define PARAM_INITIAL_SIZE 10
130
130
RDL_GraphRunCtx * gctx = RedisModule_Alloc (sizeof (* gctx ));
131
- gctx -> graph = Graph_GetShallowCopy (graph );
131
+ gctx -> graph = RDL_GraphGetShallowCopy (graph );
132
132
gctx -> inputs = array_new (RDL_GraphCtxParam , PARAM_INITIAL_SIZE );
133
133
gctx -> outputs = array_new (RDL_GraphCtxParam , PARAM_INITIAL_SIZE );
134
134
return gctx ;
@@ -143,46 +143,46 @@ static int Graph_RunCtxAddParam(RDL_GraphRunCtx* gctx, RDL_GraphCtxParam* paramA
143
143
}
144
144
RDL_GraphCtxParam param = {
145
145
.name = port ,
146
- .tensor = tensor ? Tensor_GetShallowCopy (tensor ): NULL ,
146
+ .tensor = tensor ? RDL_TensorGetShallowCopy (tensor ): NULL ,
147
147
};
148
148
paramArr = array_append (paramArr , param );
149
149
return 1 ;
150
150
}
151
151
152
- int Graph_RunCtxAddInput (RDL_GraphRunCtx * gctx , const char * inputName , RDL_Tensor * inputTensor ){
152
+ int RDL_RunCtxAddInput (RDL_GraphRunCtx * gctx , const char * inputName , RDL_Tensor * inputTensor ){
153
153
return Graph_RunCtxAddParam (gctx , gctx -> inputs , inputName , inputTensor );
154
154
}
155
155
156
- int Graph_RunCtxAddOutput (RDL_GraphRunCtx * gctx , const char * outputName ){
156
+ int RDL_RunCtxAddOutput (RDL_GraphRunCtx * gctx , const char * outputName ){
157
157
return Graph_RunCtxAddParam (gctx , gctx -> outputs , outputName , NULL );
158
158
}
159
159
160
- size_t Graph_RunCtxNumOutputs (RDL_GraphRunCtx * gctx ){
160
+ size_t RDL_RunCtxNumOutputs (RDL_GraphRunCtx * gctx ){
161
161
return array_len (gctx -> outputs );
162
162
}
163
163
164
- RDL_Tensor * Graph_RunCtxOutputTensor (RDL_GraphRunCtx * gctx , size_t index ){
165
- assert (Graph_RunCtxNumOutputs (gctx ) > index && index >= 0 );
164
+ RDL_Tensor * RDL_RunCtxOutputTensor (RDL_GraphRunCtx * gctx , size_t index ){
165
+ assert (RDL_RunCtxNumOutputs (gctx ) > index && index >= 0 );
166
166
return gctx -> outputs [index ].tensor ;
167
167
}
168
168
169
- void Graph_RunCtxFreeInternals (RDL_GraphRunCtx * gctx ){
169
+ void RDL_RunCtxFree (RDL_GraphRunCtx * gctx ){
170
170
for (size_t i = 0 ; i < array_len (gctx -> inputs ) ; ++ i ){
171
- Tensor_Free (gctx -> inputs [i ].tensor );
171
+ RDL_TensorFree (gctx -> inputs [i ].tensor );
172
172
}
173
173
array_free (gctx -> inputs );
174
174
175
175
for (size_t i = 0 ; i < array_len (gctx -> outputs ) ; ++ i ){
176
176
if (gctx -> outputs [i ].tensor ){
177
- Tensor_Free (gctx -> outputs [i ].tensor );
177
+ RDL_TensorFree (gctx -> outputs [i ].tensor );
178
178
}
179
179
}
180
180
array_free (gctx -> outputs );
181
181
182
- Graph_Free (gctx -> graph );
182
+ RDL_GraphFree (gctx -> graph );
183
183
}
184
184
185
- int Graph_Run (RDL_GraphRunCtx * gctx ){
185
+ int RDL_GraphRun (RDL_GraphRunCtx * gctx ){
186
186
TF_Status * status = TF_NewStatus ();
187
187
188
188
TF_Tensor * inputTensorsValues [array_len (gctx -> inputs )];
@@ -191,7 +191,7 @@ int Graph_Run(RDL_GraphRunCtx* gctx){
191
191
TF_Output outputs [array_len (gctx -> outputs )];
192
192
193
193
for (size_t i = 0 ; i < array_len (gctx -> inputs ) ; ++ i ){
194
- inputTensorsValues [i ] = Tensor_GetTensor (gctx -> inputs [i ].tensor );
194
+ inputTensorsValues [i ] = RDL_TensorGetTensor (gctx -> inputs [i ].tensor );
195
195
inputs [i ] = gctx -> inputs [i ].name ;
196
196
}
197
197
@@ -212,14 +212,14 @@ int Graph_Run(RDL_GraphRunCtx* gctx){
212
212
}
213
213
214
214
for (size_t i = 0 ; i < array_len (gctx -> outputs ) ; ++ i ){
215
- gctx -> outputs [i ].tensor = Tensor_CreateFromTensor (outputTensorsValues [i ]);
215
+ gctx -> outputs [i ].tensor = RDL_TensorCreateFromTensor (outputTensorsValues [i ]);
216
216
}
217
217
218
218
TF_DeleteStatus (status );
219
219
return 1 ;
220
220
}
221
221
222
- RDL_Graph * Graph_GetShallowCopy (RDL_Graph * graph ){
222
+ RDL_Graph * RDL_GraphGetShallowCopy (RDL_Graph * graph ){
223
223
++ graph -> refCount ;
224
224
return graph ;
225
225
}
0 commit comments