MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / get_flags

Function get_flags

python/paddle/base/framework.py:163–206  ·  view source on GitHub ↗

This function gets the GFlags value in Paddle. For FLAGS please refer to :ref:`en_guides_flags_flags` Args: flags(list|tuple|str): A list/tuple of string or a string which is the flag's name. Returns: flag's value in Paddle. Examples: .. code-block:: p

(flags: str | Sequence[str])

Source from the content-addressed store, hash-verified

161
162
163def get_flags(flags: str | Sequence[str]) -> dict[str, bool | str | float]:
164 """
165 This function gets the GFlags value in Paddle.
166 For FLAGS please refer to :ref:`en_guides_flags_flags`
167
168 Args:
169 flags(list|tuple|str): A list/tuple of string or a string which is the flag's name.
170
171 Returns:
172 flag's value in Paddle.
173
174 Examples:
175 .. code-block:: pycon
176
177 >>> import paddle
178
179 >>> flags = ['FLAGS_eager_delete_tensor_gb', 'FLAGS_check_nan_inf']
180 >>> res = paddle.get_flags(flags)
181 >>> print(res)
182 {'FLAGS_eager_delete_tensor_gb': 0.0, 'FLAGS_check_nan_inf': False}
183 """
184 flags_value = {}
185 if isinstance(flags, (list, tuple)):
186 for key in flags:
187 if _global_flags().is_public(key):
188 value = _global_flags()[key]
189 temp = {key: value}
190 flags_value.update(temp)
191 else:
192 raise ValueError(
193 f"Flag {key} cannot get its value through this function."
194 )
195 elif isinstance(flags, str):
196 if _global_flags().is_public(flags):
197 value = _global_flags()[flags]
198 temp = {flags: value}
199 flags_value.update(temp)
200 else:
201 raise ValueError(
202 f"Flag {flags} cannot get its value through this function."
203 )
204 else:
205 raise TypeError("Flags in get_flags should be a list, tuple or string.")
206 return flags_value
207
208
209@contextmanager

Callers 15

__init__Method · 0.90
conv2dFunction · 0.90
conv3dFunction · 0.90
__init__Method · 0.90
_in_pir_pt_modeMethod · 0.90
pir_executor_guardFunction · 0.90
implFunction · 0.90
_check_ir_outputMethod · 0.90

Calls 4

_global_flagsFunction · 0.85
ValueErrorClass · 0.85
TypeErrorClass · 0.85
updateMethod · 0.45

Tested by 3

_check_ir_outputMethod · 0.72
_check_ir_grad_outputMethod · 0.72