Skip to content

Commit 6cbeb20

Browse files
author
Han Wang
committed
print message to std:cerr and return rather than assertion.
The assertions will be bypassed in release building mode
1 parent 2644cca commit 6cbeb20

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

source/lib/src/NNPInter.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ void
190190
NNPInter::
191191
init (const string & model, const int & gpu_rank)
192192
{
193-
assert (!inited);
193+
if (inited){
194+
std::cerr << "WARNING: deepmd-kit should not be initialized twice, do nothing at the second call of initializer" << std::endl;
195+
return ;
196+
}
194197
SessionOptions options;
195198
options.config.set_inter_op_parallelism_threads(num_inter_nthreads);
196199
options.config.set_intra_op_parallelism_threads(num_intra_nthreads);
@@ -497,7 +500,10 @@ void
497500
NNPInterModelDevi::
498501
init (const vector<string> & models, const int & gpu_rank)
499502
{
500-
assert (!inited);
503+
if (inited){
504+
std::cerr << "WARNING: deepmd-kit should not be initialized twice, do nothing at the second call of initializer" << std::endl;
505+
return ;
506+
}
501507
numb_models = models.size();
502508
sessions.resize(numb_models);
503509
graph_defs.resize(numb_models);

0 commit comments

Comments
 (0)