29using KnobName = std::string;
36 virtual ~KnobLoader() =
default;
38 virtual bool load(
const KnobName &name,
bool default_value)
const = 0;
50class EnvKnobLoader final :
public KnobLoader
53 EnvKnobLoader() =
default;
56 bool load(
const KnobName &knob_name,
bool default_value)
const override
58 auto envvar = _prefix + knob_name;
59 auto s = std::getenv(envvar.c_str());
63 void knob_set(
const KnobName &knob_name,
bool value) { _knob[knob_name] = value; }
64 void dialect_set(
const exo::Dialect &dialect_name) { _prefix = _label[dialect_name]; }
65 bool knob_get(
const KnobName &knob_name) {
return load(knob_name, _knob[knob_name]); }
70 std::map<KnobName, bool> _knob;
80EnvKnobLoader &knob_loader(
void)
83 static EnvKnobLoader loader;
92#define KNOB_BOOL(NAME, TFL_DEFAULT, CIRCLE_DEFAULT, DESC) \
93 template <> typename KnobTrait<Knob::NAME>::ValueType get<Knob::NAME>(void) \
95 return ::knob_loader().knob_get(#NAME); \
102 ::knob_loader().dialect_set(d);
106#define KNOB_BOOL(NAME, TFL_DEFAULT, CIRCLE_DEFAULT, DESC) \
107 ::knob_loader().knob_set(#NAME, TFL_DEFAULT);
112#define KNOB_BOOL(NAME, TFL_DEFAULT, CIRCLE_DEFAULT, DESC) \
113 ::knob_loader().knob_set(#NAME, CIRCLE_DEFAULT);
118 std::runtime_error(
"UnKnown dialect");
int safe_strcast< int >(const char *s, const int &v)
TensorSignatures load(const char *info_path)
Function to create TensorSignatures defined in info file.