File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -127,22 +127,38 @@ std::string get_default_backend() {
127
127
return std::string (env);
128
128
}
129
129
130
+ bool get_debug_flag () {
131
+ const char * env_ = getenv (" TENSORNVME_DEBUG" );
132
+ if (env_ == nullptr ) {
133
+ return false ;
134
+ }
135
+ std::string env (env_);
136
+ std::transform (env.begin (), env.end (), env.begin (),
137
+ [](unsigned char c) { return std::tolower (c); });
138
+ return env == " 1" || env == " true" ;
139
+ }
140
+
130
141
AsyncIO *create_asyncio (unsigned int n_entries, std::string backend)
131
142
{
132
143
std::unordered_set<std::string> backends = get_backends ();
133
144
std::string default_backend = get_default_backend ();
145
+ bool is_debugging = get_debug_flag ();
134
146
135
147
if (backends.empty ())
136
148
throw std::runtime_error (" No asyncio backend is installed" );
137
149
138
150
if (default_backend.size () > 0 ) { // priority 1: environ is set
139
- std::cout << " [backend] backend is overwritten by environ TENSORNVME_BACKEND from " << backend << " to " << default_backend << std::endl;
151
+ if (is_debugging) {
152
+ std::cout << " [backend] backend is overwritten by environ TENSORNVME_BACKEND from " << backend << " to " << default_backend << std::endl;
153
+ }
140
154
backend = default_backend;
141
155
} else if (backend.size () > 0 ) { // priority 2: backend is set
142
156
if (backends.find (backend) == backends.end ())
143
157
throw std::runtime_error (" Unsupported backend: " + backend);
144
158
}
145
- std::cout << " [backend] using backend: " << backend << std::endl;
159
+ if (is_debugging) {
160
+ std::cout << " [backend] using backend: " << backend << std::endl;
161
+ }
146
162
147
163
if (!probe_backend (backend))
148
164
throw std::runtime_error (" Backend \" " + backend + " \" is not install correctly" );
Original file line number Diff line number Diff line change 1
1
#include " asyncio.h"
2
2
#include < string>
3
+ #include < algorithm>
4
+ #include < cctype>
3
5
#include < unordered_set>
4
6
#include < cstdlib>
5
7
#include < iostream>
@@ -10,4 +12,6 @@ bool probe_backend(const std::string &backend);
10
12
11
13
std::string get_default_backend ();
12
14
15
+ bool get_debug_flag ();
16
+
13
17
AsyncIO *create_asyncio (unsigned int n_entries, std::string backend);
You can’t perform that action at this time.
0 commit comments