2using System.Collections.Generic;
32 Exception m_err =
null;
43 : base(cuda, log, p, db)
48 m_internalThread.
DoWork +=
new EventHandler<ActionStateArgs<T>>(m_internalThread_DoWork);
49 m_internalThread.
OnPreStop += internalThread_OnPreStop;
50 m_internalThread.
OnPreStart += internalThread_OnPreStart;
63 private void internalThread_OnPreStart(
object sender, EventArgs e)
65 m_rgPrefetchFree.
Reset();
66 m_rgPrefetchFull.
Reset();
69 private void internalThread_OnPreStop(
object sender, EventArgs e)
71 if (m_rgPrefetchFree !=
null)
72 m_rgPrefetchFree.
Abort();
74 if (m_rgPrefetchFull !=
null)
75 m_rgPrefetchFull.
Abort();
93 if (m_rgPrefetchFull !=
null)
96 m_rgPrefetchFull =
null;
99 if (m_rgPrefetchFree !=
null)
102 m_rgPrefetchFree =
null;
119 base.LayerSetUp(colBottom, colTop);
147 get {
return false; }
172 if (m_rgPrefetchFree.
Pop(ref batch))
176 batch.Data.AsyncGpuPush(hStream);
178 m_cuda.SynchronizeStream(hStream);
182 batch.Label.AsyncGpuPush(hStream);
184 m_cuda.SynchronizeStream(hStream);
189 m_rgPrefetchFull.
Push(batch);
193 catch (Exception excpt)
196 m_rgPrefetchFull.
Abort();
197 m_rgPrefetchFree.
Abort();
224 if (m_prefetch_current !=
null)
225 m_rgPrefetchFree.
Push(m_prefetch_current);
227 if (m_rgPrefetchFull.
Pop(ref m_prefetch_current))
233 m_cuda.copy(m_prefetch_current.Data.count(), m_prefetch_current.Data.gpu_data, colTop[0].mutable_gpu_data);
248 m_cuda.copy(m_prefetch_current.Label.count(), m_prefetch_current.Label.gpu_data, colTop[1].mutable_gpu_data);
251 else if (m_err !=
null)
281 m_data =
new Blob<T>(cuda, log);
282 m_label =
new Blob<T>(cuda, log);
297 get {
return m_data; }
305 get {
return m_label; }
The CancelEvent provides an extension to the manual cancel event that allows for overriding the manua...
The Log class provides general output in text form.
void WriteLine(string str, bool bOverrideEnabled=false, bool bHeader=false, bool bError=false, bool bDisable=false)
Write a line of output.
The ActionStateArgs are sent to the DoWork event when fired from the InternalThreadEntry.
The BlobCollection contains a list of Blobs.
void ReshapeLike(BlobCollection< T > src)
Reshapes all blobs in the collection to the sizes of the source.
The Blob is the main holder of data that moves through the Layers of the Net.
The BlockingQueue is used for synchronized Queue operations.
bool Pop(ref T t)
Remove an item from the front of the queue.
virtual void Dispose(bool bDisposing)
Release all resources used by the queue.
void Reset()
Reset the abort event.
void Abort()
Cancel the blocking queue operations.
void Push(T t)
Add an item to the back of the queue.
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
void FreeStream(long h)
Free a stream.
The InternalThread manages an internal thread used for Parallel and data collection operations.
void StartInternalThread(CudaDnn< T > cuda, Log log, int nDeviceID=0, object arg=null, int nInitialDelay=0)
Starts running the internal thread function which then calls the DoWork event.
EventHandler OnPreStop
The OnPreStop event fires just after signalling the thread to stop.
bool CancellationPending
Returns whether or not a cancellation is pending.
EventHandler< ActionStateArgs< T > > DoWork
The DoWork event is the working thread function.
void StopInternalThread()
Stops the internal thread.
EventHandler OnPreStart
The OnPreStart event fires just before starting the thread.
The BaseDataLayer is the base class for data Layers that feed Blobs of data into the Net.
bool m_bOutputLabels
Specifies whether or not the Layer should output labels.
DataTransformer< T > m_transformer
Specifies the DataTransformer used to transform each data item as it loaded.
The BasePrefetchingDataLayer is the base class for data Layers that pre-fetch data before feeding the...
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
The forward override implements the functionality to load pre-fetch data and feed it into the top (ou...
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
LayerSetUp implements common data layer setup functonality, and calls DatLayerSetUp to do special dat...
override void dispose()
Releases all GPU and host resources used by the Layer.
virtual bool delayPrefetch
Specifies whether or not to delay the prefetch.
CancelEvent m_evtCancel
Specifies the cancellation event for the internal thread.
virtual void final_process(Blob< T > blobTop)
Provides a final processing step that may be utilized by derivative classes.
void statupPrefetch()
Starts the prefetch thread.
abstract void load_batch(Batch< T > batch)
The load_batch abstract function should be overriden by each derivative data Layer to load a batch of...
Batch< T >[] m_rgPrefetch
Specifies the pre-fetch cache.
BasePrefetchingDataLayer(CudaDnn< T > cuda, Log log, LayerParameter p, IXDatabaseBase db, CancelEvent evtCancel)
The BaseDataLayer constructor.
virtual void preStop()
The preStop method is called just before stopping the internal thread. Overriding this method gives d...
The Batch contains both the data and label Blobs of the batch.
void Dispose()
Release all GPU and host resources used (if any).
Blob< T > Label
Returns the label Blob of the batch.
Batch(CudaDnn< T > cuda, Log log)
The Batch constructor.
Blob< T > Data
Returns the data Blob of the batch.
Log m_log
Specifies the Log for output.
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
CudaDnn< T > m_cuda
Specifies the CudaDnn connection to Cuda.
uint prefetch
Prefetch queue (Number of batches to prefetch to host memory, increase if data access bandwidth varie...
Specifies the base parameter for all layers.
string name
Specifies the name of this LayerParameter.
DataParameter data_param
Returns the parameter set when initialized with LayerType.DATA
The IXDatabaseBase interface defines the general interface to the in-memory database.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.common namespace contains common MyCaffe classes.
The MyCaffe.db.image namespace contains all image database related classes.
The MyCaffe.layers namespace contains all layers that have a solidified code base,...
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...