MCPcopy Create free account
hub / github.com/NVIDIA/DALI / _process_argument_inputs

Function _process_argument_inputs

dali/python/nvidia/dali/ops/__init__.py:273–304  ·  view source on GitHub ↗

Process argument inputs: validate, deprecate, promote constants, add to spec and return the list of DataNodes that need to be kept alive for the graph to exist. Returns ------- List the list of DataNodes representing inputs (there may be conversions)

(schema, spec, kwargs, operator_name)

Source from the content-addressed store, hash-verified

271
272
273def _process_argument_inputs(schema, spec, kwargs, operator_name):
274 """Process argument inputs: validate, deprecate, promote constants, add to spec and return the
275 list of DataNodes that need to be kept alive for the graph to exist.
276
277 Returns
278 -------
279 List
280 the list of DataNodes representing inputs (there may be conversions)
281 """
282 kwargs = _handle_arg_deprecations(schema, kwargs, operator_name)
283 # Add argument inputs
284 result = []
285 for k in sorted(kwargs.keys()):
286 arg_inp = kwargs[k]
287 if arg_inp is None:
288 continue
289 # Argument input constants are always placed on CPU
290 # TODO(klecki): For MIS we can extract this step outside and do it once
291 arg_inp = _handle_constant(arg_inp, "cpu", k, operator_name)
292
293 if arg_inp.device != "cpu":
294 raise ValueError(
295 f"Invalid device \"{arg_inp.device}\" for argument '{k}' of operator "
296 f"'{operator_name}'. "
297 f"Named arguments must be on CPU."
298 )
299
300 _check_arg_input(schema, operator_name, k)
301
302 spec.AddArgumentInput(k, arg_inp.name, arg_inp.ndim, arg_inp.dtype, arg_inp.layout)
303 result.append(arg_inp)
304 return result
305
306
307def _process_inputs(schema, spec, inputs, operator_name):

Callers 1

__init__Method · 0.85

Calls 6

_handle_arg_deprecationsFunction · 0.85
_handle_constantFunction · 0.85
_check_arg_inputFunction · 0.85
keysMethod · 0.80
AddArgumentInputMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected