Search⌘ K

Memory-aware Array: Array Subclass in GPUData class

Explore the GPUData class implementation that subclasses NumPy's ndarray to handle memory-aware array views on CPU and GPU. Understand how it tracks data extents and pending updates to optimize synchronization and improve performance in custom vectorized applications.

As explained in the Subclassing ndarray documentation, subclassing ndarray is complicated by the fact that new instances of ndarray classes can come about in three different ways:

  • Explicit constructor call
  • View casting
  • New from template

However, our case is simpler because we’re only interested in the view casting. We thus only need to define the ...