mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-17 10:52:04 +08:00
100f89a161
* openpilot v0.9.9 release date: 2025-06-05T19:54:08 master commit: 8aadf02b2fd91f4e1285e18c2c7feb32d93b66f5 * AGNOS 12.4 (#35558) agnos12.4 --------- Co-authored-by: Vehicle Researcher <user@comma.ai> Co-authored-by: Maxime Desroches <desroches.maxime@gmail.com>
12 lines
565 B
Python
12 lines
565 B
Python
import numpy as np
|
|
from tinygrad.helpers import flat_mv
|
|
from tinygrad.device import Compiled, Allocator
|
|
|
|
class NpyAllocator(Allocator['NpyDevice']):
|
|
def _alloc(self, size:int, options=None) -> np.ndarray: return np.empty(size, dtype=np.uint8)
|
|
def _as_buffer(self, src:np.ndarray) -> memoryview: return flat_mv(np.require(src, requirements='C').data)
|
|
def _copyout(self, dest:memoryview, src:np.ndarray): dest[:] = self._as_buffer(src)
|
|
|
|
class NpyDevice(Compiled):
|
|
def __init__(self, device:str): super().__init__(device, NpyAllocator(self), None, None, None)
|