2using System.Collections.Generic;
24 int m_nCurrentBatchIdx = 0;
25 int m_nLastBatchIdx = 0;
27 bool m_bBufferFull =
false;
47 m_rgBatchData.Dispose();
57 get {
return m_rgBatchData; }
65 get {
return m_rgBatchLabels; }
81 get {
return m_cuda.KernelHandle; }
89 get {
return (m_bBufferFull) ? m_rgBatchData.Count : m_nCurrentBatchIdx; }
115 m_log.
CHECK_GE(colBottom.
Count, 2,
"There should be at least two bottom items: data (embeddings) and labels.");
119 for (
int i = 0; i < m_nMaxBatches; i++)
122 data.ReshapeLike(colBottom[0]);
123 m_rgBatchData.Add(
data);
127 m_rgBatchLabels.
Add(label);
142 for (
int i = 0; i < m_nMaxBatches; i++)
144 m_rgBatchData[i].ReshapeLike(colBottom[0]);
156 if (m_nCurrentBatchIdx == m_nMaxBatches)
158 m_nCurrentBatchIdx = 0;
159 m_bBufferFull =
true;
163 m_cuda.copy(colBottom[0].count(), colBottom[0].gpu_data, m_rgBatchData[m_nCurrentBatchIdx].mutable_gpu_data);
164 m_cuda.copy(colBottom[1].count(), colBottom[1].gpu_data, m_rgBatchLabels[m_nCurrentBatchIdx].mutable_gpu_data);
166 m_nLastBatchIdx = m_nCurrentBatchIdx;
167 m_nCurrentBatchIdx++;
169 m_cuda.copy(colBottom[0].count(), colBottom[0].gpu_data, colTop[0].mutable_gpu_data);
181 m_cuda.copy(colTop[0].count(), colTop[0].gpu_diff, m_rgBatchData[m_nLastBatchIdx].mutable_gpu_diff);
183 m_cuda.copy(colTop[0].count(), colTop[0].gpu_diff, colBottom[0].mutable_gpu_diff);
The Log class provides general output in text form.
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
void CHECK_GE(double df1, double df2, string str)
Test whether one number is greater than or equal to another.
The BlobCollection contains a list of Blobs.
void Dispose()
Release all resource used by the collection and its Blobs.
void Add(Blob< T > b)
Add a new Blob to the collection.
int Count
Returns the number of items in the collection.
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.
Blob(CudaDnn< T > cuda, Log log, bool bIncludeDiff=true, bool bUseHalfSize=false)
The Blob constructor.
void ReshapeLike(Blob< T > b, bool? bUseHalfSize=null)
Reshape this Blob to have the same shape as another Blob.
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
The DebugLayer merely stores, up to max_stored_batches, batches of input which are then optionally us...
BlobCollection< T > data
Returns a collection of Blobs containing the data stored by the DebugLayer.
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Setup the layer.
BlobCollection< T > labels
Returns a collection of Blobs containing the labels stored by the DebugLayer.
override void dispose()
Releases all GPU and host resources used by the Layer.
override int MinTopBlobs
Returns the minimum number of top (output) Blobs: data (passthrough)
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Forward cache and pass through
override void Reshape(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Reshape the top (output) to match the bottom (input), and reshape internal buffers.
string name
Returns the name of the DebugLayer.
DebugLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The DebugLayer constructor.
override int MinBottomBlobs
Returns the minimum number of required bottom (input) Blobs: data, label
int? load_count
Returns the number of batches actually loaded into the DebugLayer.
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Backward passthrough
long kernel_handle
Returns the handle to the CudaDnn kernel where the debug GPU memory resides.
An interface for the units of computation which can be composed into a Net.
Log m_log
Specifies the Log for output.
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
virtual bool reshapeNeeded(BlobCollection< T > colBottom, BlobCollection< T > colTop, bool bReset=true)
Tests the shapes of both the bottom and top blobs and if they are the same as the previous sizing,...
CudaDnn< T > m_cuda
Specifies the CudaDnn connection to Cuda.
LayerParameter.LayerType m_type
Specifies the Layer type.
int max_stored_batches
Specifies the maximum number of batches to store and search for neighbors. Each batch input is stored...
Specifies the base parameter for all layers.
string name
Specifies the name of this LayerParameter.
DebugParameter debug_param
Returns the parameter set when initialized with LayerType.DEBUG
LayerType
Specifies the layer type.
The IXDebugData interface is implemented by the DebugLayer to give access to the debug information ma...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.common namespace contains common MyCaffe 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-...