MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / get_params_info

Method get_params_info

bench/python/bench_utils.py:112–154  ·  view source on GitHub ↗

Returns a dictionary with keys being the variable names initialized exclusively during the setup call # and values being their values. Useful to log if someone wants to know what parameters were used to initialize the operator in the setup function call. :param primi

(self, primitive_types_only=True)

Source from the content-addressed store, hash-verified

110 pass
111
112 def get_params_info(self, primitive_types_only=True):
113 """
114 Returns a dictionary with keys being the variable names initialized exclusively during the setup call
115 # and values being their values. Useful to log if someone wants to know what parameters were used to
116 initialize the operator in the setup function call.
117 :param primitive_types_only: Only includes attributes with primitive data-types if True. Primitive
118 data types are bool, str, int, float, tuple and None.
119 """
120 primitives = (bool, str, int, float, tuple, type(None))
121
122 # Get all global names (e.g variables + function names) used by the setup function.
123 all_global_names_setup_func = set(self.setup.__code__.co_names)
124
125 # Get all the global names (e.g variables + function names) used by the __init__ function.
126 all_global_names_init_func = set(self.__init__.__code__.co_names)
127
128 # Remove the names already used by __init__ from the ones used by setup to get a list of names
129 # which are exclusively used by setup
130 all_global_names_setup_func -= all_global_names_init_func
131
132 # Get all the variables of this class.
133 all_vars_info = vars(self)
134 all_vars_names = set(all_vars_info.keys())
135
136 # Figure out all global variables only by intersecting the all_vars_names with
137 # all_global_names_setup_func.
138 # That will eliminate the global function names from all_global_names_setup_func.
139 vars_names_of_setup_function = all_vars_names.intersection(
140 all_global_names_setup_func
141 )
142
143 if primitive_types_only:
144 vars_info_of_setup_function = {
145 v: all_vars_info[v]
146 for v in vars_names_of_setup_function
147 if isinstance(all_vars_info[v], primitives)
148 }
149 else:
150 vars_info_of_setup_function = {
151 v: all_vars_info[v] for v in vars_names_of_setup_function
152 }
153
154 return vars_info_of_setup_function
155
156 def _setup_clear_output_dir(self, filename_ends_with):
157 output_dir = os.path.join(self.output_dir, self.__class__.__name__)

Callers 1

run_benchFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected