INNER CODE UNIT · Python

time

onnxsim/onnxsim · onnxsim/rpc/server.py:154

    def time(self, inputs: Dict[str, np.ndarray], number: int, repeat: int):
        """(per-call seconds, statistics), measuring steady-state ``TinyJit`` replays.

        Replaying a captured graph removes the Python ONNX interpreter's per-call cost, so the
        numbers reflect the generated kernels. ``stats`` also carries the eager (interpreted) call
        time and, from one replay under ``DEBUG=2``, device kernel time, FLOPs and bytes moved.
        """
        import contextlib
        import io

        from tinygrad import TinyJit
        from tinygrad.helpers import Context, GlobalCounters

        tensors = self._to_device(inputs)
        names = list(tensors)
        eager_start = time.perf_counter()
        self._forward(tensors)  # first call also compiles the kernels
        self._Device[self.device].synchronize()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…