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

Method __init__

dali/python/nvidia/dali/experimental/dynamic/_ops.py:157–213  ·  view source on GitHub ↗

Constructs an operator instance Parameters ---------- max_batch_size : int The maximum batch size for this operator instance. name : str, optional The name of the operator instance. device : Device or str, optional The devic

(
        self,
        max_batch_size,
        name=None,
        device="cpu",
        *,
        _backend=None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

155 _generated = False
156
157 def __init__(
158 self,
159 max_batch_size,
160 name=None,
161 device="cpu",
162 *,
163 _backend=None,
164 **kwargs,
165 ):
166 """Constructs an operator instance
167 Parameters
168 ----------
169 max_batch_size : int
170 The maximum batch size for this operator instance.
171 name : str, optional
172 The name of the operator instance.
173 device : Device or str, optional
174 The device where the operation is executed.
175 """
176 self._lock = Lock()
177 self._name = name
178 self._max_batch_size = max_batch_size
179 self._init_args = kwargs
180 self._api_type = None
181 self._is_copy = self._schema_name == "Copy"
182
183 self._device = _device.device(device)
184 if _backend is None:
185 if self._device.device_type in self._supported_backends:
186 _backend = self._device.device_type
187 elif self._device.device_type == "gpu" and "mixed" in self._supported_backends:
188 _backend = "mixed"
189 else:
190 raise ValueError(f'Invalid device "{device}" for operator `{self._schema_name}`')
191 else:
192 # _backend is an internal parameter - once it's passed explicitly, it must be correct
193 assert _backend in self._supported_backends, "Internal error: incompatible backend."
194 self._backend = _backend
195
196 # Information below is lazy-initialized
197 # TODO(klecki): Use @property or @cached_property for self-init.
198
199 # Metadata about batch/sample, layout, dim and type. See _make_meta() for more details.
200 self._input_meta = []
201 self._arg_meta = {}
202 # Number of outputs
203 self._num_outputs = None
204 # When an operator (e.g. TFRecord) returns a dictionary, outputs are named
205 self._output_names = None
206 # Expected device placement of the outputs
207 self._output_devices = None
208 # Instance of the legacy Python Operator from the nvidia.dali.ops module
209 self._op_inst = None
210 # Instance of the C++ OperatorBase class - used for direct invocation of operator
211 self._op_backend = None
212 self._op_spec = None
213 self._last_invocation = None
214

Callers

nothing calls this directly

Calls 1

deviceMethod · 0.45

Tested by

no test coverage detected