Process inputs: validate, 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, inputs, operator_name)
| 305 | |
| 306 | |
| 307 | def _process_inputs(schema, spec, inputs, operator_name): |
| 308 | """Process inputs: validate, add to spec and return the list of DataNodes that need to be kept |
| 309 | alive for the graph to exist. |
| 310 | |
| 311 | Returns |
| 312 | ------- |
| 313 | List |
| 314 | the list of DataNodes representing inputs (there may be conversions) |
| 315 | """ |
| 316 | if len(inputs) < schema.MinNumInput() or len(inputs) > schema.MaxNumInput(): |
| 317 | raise ValueError( |
| 318 | f"Operator {operator_name} expects " |
| 319 | f"from {schema.MinNumInput()} to {schema.MaxNumInput()} inputs, " |
| 320 | f"but received {len(inputs)}." |
| 321 | ) |
| 322 | if not inputs: |
| 323 | return [] |
| 324 | for inp in inputs: |
| 325 | if not isinstance(inp, _DataNode): |
| 326 | raise TypeError(f"Expected inputs of type 'DataNode'. Received input of type '{inp}'.") |
| 327 | spec.AddInput(inp.name, inp.device, inp.ndim, inp.dtype, inp.layout) |
| 328 | return list(inputs) |
| 329 | |
| 330 | |
| 331 | def _add_spec_args(schema, spec, kwargs): |
no test coverage detected