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() {
127127 return std::string (env);
128128}
129129
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+
130141AsyncIO *create_asyncio (unsigned int n_entries, std::string backend)
131142{
132143 std::unordered_set<std::string> backends = get_backends ();
133144 std::string default_backend = get_default_backend ();
145+ bool is_debugging = get_debug_flag ();
134146
135147 if (backends.empty ())
136148 throw std::runtime_error (" No asyncio backend is installed" );
137149
138150 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+ }
140154 backend = default_backend;
141155 } else if (backend.size () > 0 ) { // priority 2: backend is set
142156 if (backends.find (backend) == backends.end ())
143157 throw std::runtime_error (" Unsupported backend: " + backend);
144158 }
145- std::cout << " [backend] using backend: " << backend << std::endl;
159+ if (is_debugging) {
160+ std::cout << " [backend] using backend: " << backend << std::endl;
161+ }
146162
147163 if (!probe_backend (backend))
148164 throw std::runtime_error (" Backend \" " + backend + " \" is not install correctly" );
Original file line number Diff line number Diff line change 11#include " asyncio.h"
22#include < string>
3+ #include < algorithm>
4+ #include < cctype>
35#include < unordered_set>
46#include < cstdlib>
57#include < iostream>
@@ -10,4 +12,6 @@ bool probe_backend(const std::string &backend);
1012
1113std::string get_default_backend ();
1214
15+ bool get_debug_flag ();
16+
1317AsyncIO *create_asyncio (unsigned int n_entries, std::string backend);
You can’t perform that action at this time.
0 commit comments