MCPcopy Create free account
hub / github.com/BVLC/caffe / LayerSetUp

Method LayerSetUp

src/caffe/layers/dummy_data_layer.cpp:9–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8template <typename Dtype>
9void DummyDataLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
10 const vector<Blob<Dtype>*>& top) {
11 const int num_top = top.size();
12 const DummyDataParameter& param = this->layer_param_.dummy_data_param();
13 const int num_data_filler = param.data_filler_size();
14 CHECK(num_data_filler == 0 || num_data_filler == 1 ||
15 num_data_filler == num_top)
16 << "Number of data fillers must be 0, 1 or equal to the number of tops: "
17 << num_top << "; you specified " << num_data_filler << " data fillers.";
18
19 const bool legacy_dims = param.num_size() || param.channels_size() ||
20 param.height_size() || param.width_size();
21 if (legacy_dims) {
22 CHECK_EQ(0, param.shape_size())
23 << "Both shape and legacy fields were specified";
24 // Using deprecated 4D output dim specifiers.
25 CHECK(param.num_size() == 1 || param.num_size() == num_top)
26 << "Must specify 'num' once, or once per top blob "
27 << "(" << num_top << "); specified " << param.num_size() << ".";
28 CHECK(param.channels_size() == 1 || param.channels_size() == num_top)
29 << "Must specify 'channels' once, or once per top blob "
30 << "(" << num_top << "); specified " << param.channels_size() << ".";
31 CHECK(param.height_size() == 1 || param.height_size() == num_top)
32 << "Must specify 'height' once, or once per top blob "
33 << "(" << num_top << "); specified " << param.height_size() << ".";
34 CHECK(param.width_size() == 1 || param.width_size() == num_top)
35 << "Must specify 'width' once, or once per top blob "
36 << "(" << num_top << "); specified " << param.width_size() << ".";
37 } else {
38 CHECK(param.shape_size() == 1 || param.shape_size() == num_top)
39 << "Must specify 'shape' once, or once per top blob "
40 << "(" << num_top << "); specified " << param.shape_size() << ".";
41 }
42 // refill_[i] tells Forward i whether or not to actually refill top Blob i.
43 // If refill_[i] is false, Forward does nothing for Blob i. We use this to
44 // avoid wastefully refilling "constant" Blobs in every forward pass.
45 // We first fill refill_ in with the INVERSE of its final values.
46 // The first time we run Forward from the LayerSetUp method, we'll fill only
47 // Blobs for which refill_ is normally false. These Blobs will never be
48 // filled again.
49 refill_.clear();
50 fillers_.clear();
51 if (num_data_filler <= 1) {
52 FillerParameter filler_param;
53 if (num_data_filler == 0) {
54 filler_param.set_type("constant");
55 filler_param.set_value(0);
56 } else {
57 filler_param.CopyFrom(param.data_filler(0));
58 }
59 // Refill on each iteration iff not using a constant filler,
60 // but use the inverse of this rule for the first run.
61 refill_.resize(1);
62 refill_[0] = (strcmp(filler_param.type().c_str(), "constant") == 0);
63 fillers_.resize(1);
64 fillers_[0].reset(GetFiller<Dtype>(filler_param));
65 } else {
66 refill_.resize(num_top);

Callers

nothing calls this directly

Calls 11

CopyFromMethod · 0.80
numMethod · 0.80
shapeMethod · 0.80
ForwardMethod · 0.80
sizeMethod · 0.45
typeMethod · 0.45
resetMethod · 0.45
channelsMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45
ReshapeMethod · 0.45

Tested by

no test coverage detected