class nbla::Array

class Array : public std::enable_shared_from_this<Array>

An abstract class of Array interface.Shared pointer of NdArray.

This is extended to implement a new array class (see CpuArray, CudaArray etc.).

Subclassed by nbla::CpuArray, nbla::DlpackArray

Public Functions

template<typename T = void>
inline T *pointer()

Get object pointer.

template<typename T = void>
inline const T *const_pointer() const

Get constant object pointer.

inline AllocatorMemoryPtr memory() const

Get shared pointer of the AllocatorMemory.

inline Size_t offset() const

Get offset.

inline dtypes dtype() const

Return dtype.

inline Size_t size() const

Return size of descendant dimensions of specified axis.

inline Context context() const

Return context.

virtual void copy_from(const Array *src_array) = 0

Copy from Array.

virtual NBLA_API void zero ()=0

Fill all element with zero.

virtual NBLA_API void fill (float value)=0

Fill all element with given value.

virtual NBLA_API void set_event (EventPtr eptr)

Set an event.

virtual NBLA_API void wait_event (const Context ctx, const int async_flags=AsyncFlag::NONE)

Wait for the end of an event.

Parameters:
  • ctxContext where the event is waited for.

  • async_flags – .

virtual NBLA_API bool have_event ()

Check an event exist.

virtual NBLA_API Ptr getptr ()

Get shared_ptr of this object.

Public Static Functions

static Context filter_context(const Context &ctx)

Filter a Context into a minimal information to describe an Array.