INNER CODE UNIT · Python

array

onnx/onnx-tensorrt · onnx_tensorrt/tensorrt_engine.py:83

    def array(self, data: Union[np.ndarray, bytes]):
        """Set the array data with proper bounds checking"""
        host_array = self.array  # Get the numpy array view
        if isinstance(data, np.ndarray):
            if data.size > self._host_size:
                raise ValueError(
                    f"Tried to fit an array of size {data.size} into host memory of size {self._host_size}"
                )
            np.copyto(host_array[:data.size], data.flat, casting='safe')
        else:
            assert self._dtype == np.uint8
            host_array[:self.nbytes] = np.frombuffer(data, dtype=np.uint8)

    @property
    def nbytes(self) -> int:
        return self._nbytes

    def free(self):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…