@@ -419,27 +419,27 @@ void RAI_ModelFreeTF(RAI_Model* model, RAI_Error* error) {
419419 TF_DeleteStatus (status );
420420}
421421
422- int RAI_ModelRunTF (RAI_ModelRunCtx * mctx , RAI_Error * error ) {
422+ int RAI_ModelRunTF (RAI_ModelRunCtx * * mctxs , RAI_Error * error ) {
423423 TF_Status * status = TF_NewStatus ();
424424
425- const size_t nbatches = array_len (mctx -> batches );
425+ const size_t nbatches = array_len (mctxs );
426426 if (nbatches == 0 ) {
427427 RAI_SetError (error , RAI_EMODELRUN , "ERR No batches to run" );
428428 return 1 ;
429429 }
430430
431- const size_t ninputs = array_len (mctx -> batches [0 ]. inputs );
432- const size_t noutputs = array_len (mctx -> batches [0 ]. outputs );
431+ const size_t ninputs = array_len (mctxs [0 ]-> inputs );
432+ const size_t noutputs = array_len (mctxs [0 ]-> outputs );
433433 TF_Tensor * inputTensorsValues [ninputs ];
434434 TF_Output inputs [ninputs ];
435435 TF_Tensor * outputTensorsValues [noutputs ];
436436 TF_Output outputs [noutputs ];
437437
438438 size_t batch_sizes [nbatches ];
439439 size_t batch_offsets [nbatches ];
440- if (array_len (mctx -> batches [0 ]. inputs ) > 0 ) {
440+ if (array_len (mctxs [0 ]-> inputs ) > 0 ) {
441441 for (size_t b = 0 ; b < nbatches ; ++ b ) {
442- batch_sizes [b ] = RAI_TensorDim (mctx -> batches [b ]. inputs [0 ].tensor , 0 );
442+ batch_sizes [b ] = RAI_TensorDim (mctxs [b ]-> inputs [0 ].tensor , 0 );
443443 }
444444 batch_offsets [0 ] = 0 ;
445445 for (size_t b = 1 ; b < nbatches ; ++ b ) {
@@ -451,12 +451,12 @@ int RAI_ModelRunTF(RAI_ModelRunCtx* mctx, RAI_Error *error) {
451451 RAI_Tensor * batched_input_tensors [nbatches ];
452452
453453 for (size_t b = 0 ; b < nbatches ; ++ b ) {
454- batched_input_tensors [b ] = mctx -> batches [b ]. inputs [i ].tensor ;
454+ batched_input_tensors [b ] = mctxs [b ]-> inputs [i ].tensor ;
455455 }
456456 // inputTensorsValues[i] = RAI_TFTensorFromTensor(mctx->inputs[i].tensor);
457457 inputTensorsValues [i ] = RAI_TFTensorFromTensors (batched_input_tensors , nbatches );
458458 TF_Output port ;
459- port .oper = TF_GraphOperationByName (mctx -> model -> model , mctx -> batches [0 ]. inputs [i ].name );
459+ port .oper = TF_GraphOperationByName (mctxs [ 0 ] -> model -> model , mctxs [0 ]-> inputs [i ].name );
460460 port .index = 0 ;
461461 if (port .oper == NULL ){
462462 return 1 ;
@@ -466,15 +466,15 @@ int RAI_ModelRunTF(RAI_ModelRunCtx* mctx, RAI_Error *error) {
466466
467467 for (size_t i = 0 ; i < noutputs ; ++ i ) {
468468 TF_Output port ;
469- port .oper = TF_GraphOperationByName (mctx -> model -> model , mctx -> batches [0 ]. outputs [i ].name );
469+ port .oper = TF_GraphOperationByName (mctxs [ 0 ] -> model -> model , mctxs [0 ]-> outputs [i ].name );
470470 port .index = 0 ;
471471 if (port .oper == NULL ){
472472 return 1 ;
473473 }
474474 outputs [i ] = port ;
475475 }
476476
477- TF_SessionRun (mctx -> model -> session , NULL /* run_options */ ,
477+ TF_SessionRun (mctxs [ 0 ] -> model -> session , NULL /* run_options */ ,
478478 inputs , inputTensorsValues , ninputs ,
479479 outputs , outputTensorsValues , noutputs ,
480480 NULL /* target_opers */ , 0 /* ntargets */ ,
@@ -496,7 +496,7 @@ int RAI_ModelRunTF(RAI_ModelRunCtx* mctx, RAI_Error *error) {
496496 for (size_t i = 0 ; i < noutputs ; ++ i ) {
497497 for (size_t b = 0 ; b < nbatches ; b ++ ) {
498498 RAI_Tensor * output_tensor = RAI_TensorCreateFromTFTensor (outputTensorsValues [i ], batch_offsets [b ], batch_sizes [b ]);
499- mctx -> batches [b ]. outputs [i ].tensor = RAI_TensorGetShallowCopy (output_tensor );
499+ mctxs [b ]-> outputs [i ].tensor = RAI_TensorGetShallowCopy (output_tensor );
500500 RAI_TensorFree (output_tensor );
501501 }
502502 TF_DeleteTensor (outputTensorsValues [i ]);
0 commit comments