ONE - On-device Neural Engine
Loading...
Searching...
No Matches
MemoryTracker Class Reference

#include <MemoryTracker.h>

Public Member Functions

uint32_t add (const Memory *memory)
 
uint32_t size () const
 
const Memoryoperator[] (size_t i) const
 

Detailed Description

Definition at line 31 of file MemoryTracker.h.

Member Function Documentation

◆ add()

uint32_t MemoryTracker::add ( const Memory memory)

Definition at line 28 of file MemoryTracker.cpp.

29{
30 VLOG(MODEL) << __func__ << " for " << memory;
31 // See if we already have this memory. If so,
32 // return its index.
33 auto i = mKnown.find(memory);
34 if (i != mKnown.end())
35 {
36 return i->second;
37 }
38 VLOG(MODEL) << "It's new";
39 // It's a new one. Save it an assign an index to it.
40 size_t next = mKnown.size();
41 if (next > 0xFFFFFFFF)
42 {
43 LOG(ERROR) << "ANeuralNetworks more than 2^32 memories.";
45 }
46 uint32_t idx = static_cast<uint32_t>(next);
47 mKnown[memory] = idx;
48 mMemories.push_back(memory);
49 return idx;
50}
#define LOG(...)
Definition Logging.h:36
#define VLOG(...)
Definition Logging.h:37
@ ANEURALNETWORKS_BAD_DATA

References ANEURALNETWORKS_BAD_DATA, LOG, and VLOG.

Referenced by ExecutionBuilder::setInputFromMemory(), ModelBuilder::setOperandValueFromMemory(), and ExecutionBuilder::setOutputFromMemory().

◆ operator[]()

const Memory * MemoryTracker::operator[] ( size_t  i) const
inline

Definition at line 40 of file MemoryTracker.h.

40{ return mMemories[i]; }

◆ size()

uint32_t MemoryTracker::size ( ) const
inline

Definition at line 38 of file MemoryTracker.h.

38{ return static_cast<uint32_t>(mKnown.size()); }

Referenced by ModelBuilder::publish(), and ExecutionBuilder::startCompute().


The documentation for this class was generated from the following files: