Class representing the operator node in DALI Pipeline/graph. The entry point accepts grouped arguments: inputs (positional arguments with DataNodes), arguments (dictionary with scalar values), and argument inputs (dictionary with DataNodes). It is responsible for the full* validation of
| 345 | |
| 346 | |
| 347 | class _OperatorInstance(object): |
| 348 | """Class representing the operator node in DALI Pipeline/graph. |
| 349 | The entry point accepts grouped arguments: inputs (positional arguments with DataNodes), |
| 350 | arguments (dictionary with scalar values), and argument inputs (dictionary with DataNodes). |
| 351 | |
| 352 | It is responsible for the full* validation of the three input/argument kinds and their |
| 353 | additional processing (scalar promotions, deprecations and renaming, splitting for conditionals) |
| 354 | |
| 355 | Each "_process_[arguments/inputs]" step adds them to the OpSpec specifying the operator for |
| 356 | the C++ backend. |
| 357 | |
| 358 | * some validation is done in class Operator.__init__ due to legacy reasons. |
| 359 | This is the reason for `_processed_arguments` constructor parameter. |
| 360 | """ |
| 361 | |
| 362 | def __init__(self, inputs, arg_inputs, arguments, _processed_arguments, op): |
| 363 | """Construct the OperatorInstance and handle the processing of all inputs and arguments. |
| 364 | |
| 365 | Parameters |
| 366 | ---------- |
| 367 | inputs : tuple of DataNode |
| 368 | Positional inputs to operator instance. |
| 369 | arg_inputs : dict of DataNode |
| 370 | Argument inputs - named DataNode inputs to operator. |
| 371 | arguments : dict of scalar values |
| 372 | Scalar arguments to be added to OpSpec. |
| 373 | _processed_arguments : dict of scalar values |
| 374 | Remaining scalar arguments. Available here for completeness, for historical reasons |
| 375 | already validated in Operator.__init__. |
| 376 | NOTE: they are already added to the `op.spec`! |
| 377 | op : Operator class. |
| 378 | Operator class containing the schema, and spec filled with `processed_arguments`. |
| 379 | """ |
| 380 | |
| 381 | if _Pipeline.current(): |
| 382 | self._pipeline = weakref.ref(_Pipeline.current()) |
| 383 | else: |
| 384 | self._pipeline = None |
| 385 | self._id = None |
| 386 | self._outputs = [] |
| 387 | self._op = op |
| 388 | self._spec = op.spec.copy() |
| 389 | self._relation_id = None |
| 390 | |
| 391 | if _conditionals.conditionals_enabled(): |
| 392 | inputs, arg_inputs = _conditionals.apply_conditional_split_to_args(inputs, arg_inputs) |
| 393 | _conditionals.inject_implicit_scope_argument(op._schema, arg_inputs) |
| 394 | |
| 395 | self._process_instance_name(arguments) |
| 396 | self._process_trace(arguments) |
| 397 | self._spec.AddArg("preserve_name", not self._autoname) |
| 398 | _process_arguments(op._schema, self._spec, arguments, op._operator_name()) |
| 399 | |
| 400 | self._inputs = _process_inputs(op._schema, self._spec, inputs, op._operator_name()) |
| 401 | self._inputs += _process_argument_inputs( |
| 402 | op._schema, self._spec, arg_inputs, op._operator_name() |
| 403 | ) |
| 404 |