MCPcopy Create free account
hub / github.com/Xilinx/CHaiDNN / ExtractCaffeMeanData

Function ExtractCaffeMeanData

software/xtract/caffe_network_parser.cpp:3083–3106  ·  view source on GitHub ↗

Extract the mean data

Source from the content-addressed store, hash-verified

3081
3082// Extract the mean data
3083void ExtractCaffeMeanData(const caffe::BlobProto* blob, XGraph* graph)
3084{
3085 // Extract the mean data itself
3086 graph->meanData.reserve(blob->data_size());
3087 copy(blob->data().begin(), blob->data().end(), std::back_inserter(graph->meanData));
3088
3089 // Extract the mean shape
3090 // Caffe compute_mean() still uses deprecated API. So be ready for both
3091 caffe::BlobShape shape = blob->shape();
3092 if(shape.dim_size() > 0)
3093 {
3094 graph->meanShape.reserve(shape.dim_size());
3095 copy(shape.dim().begin(), shape.dim().end(), std::back_inserter(graph->meanShape));
3096 }
3097 else
3098 {
3099 // Use vector.reserve only if you do push_back() else use vector.resize() only
3100 graph->meanShape.resize(4);
3101 graph->meanShape.at(0) = 1;
3102 graph->meanShape.at(1) = blob->has_channels() ? blob->channels() : 1;
3103 graph->meanShape.at(2) = blob->has_height() ? blob->height() : 1;
3104 graph->meanShape.at(3) = blob->has_width() ? blob->width() : graph->meanData.size();
3105 }
3106}
3107
3108#define CHECK_PRECISION(condn, variable, true_value, default_value) \
3109 if(condn) \

Callers 1

ParseCaffeNetworkFunction · 0.85

Calls 15

data_sizeMethod · 0.80
shapeMethod · 0.80
dim_sizeMethod · 0.80
dimMethod · 0.80
has_channelsMethod · 0.80
has_heightMethod · 0.80
has_widthMethod · 0.80
beginMethod · 0.45
dataMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected