Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src_erl/NerlnetApp/src/Bridge/nerlTensor.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

-define(NUMOF_DIMS,3).
% nif return timeouts
-define(PREDICT_TIMEOUT,600000). % 600 seconds limit for prediction results
-define(TRAIN_TIMEOUT,600000). % 600 seconds limit for training results
-define(PREDICT_TIMEOUT,6000000). % 600 seconds limit for prediction results
-define(TRAIN_TIMEOUT,6000000). % 600 seconds limit for training results

%% nerlNIF defines
-define(NERLNET_LIB,"libnerlnet_onn").
Expand Down
20 changes: 11 additions & 9 deletions src_erl/NerlnetApp/src/Bridge/onnWorkers/nerlNIF.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ start_train_negotiator(ModelID, WorkerPid) ->
stop_train_negotiator() ->
TrainNegotiatorPID = get(nerlnif_train_negotiator_pid),
TrainNegotiatorPID ! {nerlnif_stop_train},
put(nerlnif_train_negotiator_pid, undefined),
ok.

train_negotiator(ModelID, WorkerPid, BatchID, SourceName) ->
Expand All @@ -74,10 +75,10 @@ train_negotiator(ModelID, WorkerPid, BatchID, SourceName) ->
gen_statem:cast(WorkerPid,{loss, {LossTensor, LossTensorType} , TrainTime , BatchID , SourceName}), train_negotiator(ModelID, WorkerPid, BatchID, SourceName);
{nerlnif_stop_train} ->
ok
after ?TRAIN_TIMEOUT -> %TODO inspect this timeout
?LOG_ERROR("Worker train timeout reached! bid:~p s:~p",[BatchID , SourceName]),
gen_statem:cast(WorkerPid,{loss, timeout , BatchID , SourceName}),
train_negotiator(ModelID, WorkerPid, BatchID, SourceName)
% after ?TRAIN_TIMEOUT -> %TODO inspect this timeout
% ?LOG_ERROR("Worker train timeout reached! bid:~p s:~p",[BatchID , SourceName]),
% gen_statem:cast(WorkerPid,{loss, timeout , BatchID , SourceName}),
% train_negotiator(ModelID, WorkerPid, BatchID, SourceName)
end.

call_to_train(ModelID, {DataTensor, Type} , BatchID , SourceName) ->
Expand All @@ -96,6 +97,7 @@ start_predict_negotiator(ModelID, WorkerPid) ->
stop_predict_negotiator() ->
PredictNegotiatorPID = get(nerlnif_predict_negotiator_pid),
PredictNegotiatorPID ! {nerlnif_stop_predict},
put(nerlnif_predict_negotiator_pid, undefined),
ok.

predict_negotiator(ModelID, WorkerPid, BatchID, SourceName) ->
Expand All @@ -108,11 +110,11 @@ predict_negotiator(ModelID, WorkerPid, BatchID, SourceName) ->
predict_negotiator(ModelID, WorkerPid, BatchID, SourceName);
{nerlnif_stop_predict} ->
ok
after ?PREDICT_TIMEOUT ->
% worker miss predict batch TODO - inspect this code
?LOG_ERROR("Worker prediction timeout reached! ~n "),
gen_statem:cast(WorkerPid,{predictRes, nan, BatchID , SourceName}),
predict_negotiator(ModelID, WorkerPid, BatchID, SourceName)
% after ?PREDICT_TIMEOUT ->
% % worker miss predict batch TODO - inspect this code
% ?LOG_ERROR("Worker prediction timeout reached! ~n "),
% gen_statem:cast(WorkerPid,{predictRes, timeout, BatchID , SourceName}),
% predict_negotiator(ModelID, WorkerPid, BatchID, SourceName)
end.

call_to_predict(ModelID, {BatchTensor, Type} , BatchID , SourceName)->
Expand Down
5 changes: 0 additions & 5 deletions src_erl/NerlnetApp/src/Bridge/onnWorkers/workerGeneric.erl
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ terminate(_Reason, _StateName, _State) ->
% stop negotiators
nerlNIF:stop_train_negotiator(),
nerlNIF:stop_predict_negotiator(),
% free nif resources
ModelID = get(model_id),
nerlNIF:free_nerlworker_nif(ModelID),
% delete ets table
ets:delete(get(generic_worker_ets)),
ok.

%% @private
Expand Down