MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / FromProto

Method FromProto

rtpose_wrapper/src/caffe/blob.cpp:448–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446
447template <typename Dtype>
448void Blob<Dtype>::FromProto(const BlobProto& proto, bool reshape) {
449 if (reshape) {
450 vector<int> shape;
451 if (proto.has_num() || proto.has_channels() ||
452 proto.has_height() || proto.has_width()) {
453 // Using deprecated 4D Blob dimensions --
454 // shape is (num, channels, height, width).
455 shape.resize(4);
456 shape[0] = proto.num();
457 shape[1] = proto.channels();
458 shape[2] = proto.height();
459 shape[3] = proto.width();
460 } else {
461 shape.resize(proto.shape().dim_size());
462 for (int i = 0; i < proto.shape().dim_size(); ++i) {
463 shape[i] = proto.shape().dim(i);
464 }
465 }
466 Reshape(shape);
467 } else {
468 CHECK(ShapeEquals(proto)) << "shape mismatch (reshape not set)";
469 }
470 // copy data
471 Dtype* data_vec = mutable_cpu_data();
472 if (proto.double_data_size() > 0) {
473 CHECK_EQ(count_, proto.double_data_size());
474 for (int i = 0; i < count_; ++i) {
475 data_vec[i] = proto.double_data(i);
476 }
477 } else {
478 CHECK_EQ(count_, proto.data_size());
479 for (int i = 0; i < count_; ++i) {
480 data_vec[i] = proto.data(i);
481 }
482 }
483 if (proto.double_diff_size() > 0) {
484 CHECK_EQ(count_, proto.double_diff_size());
485 Dtype* diff_vec = mutable_cpu_diff();
486 for (int i = 0; i < count_; ++i) {
487 diff_vec[i] = proto.double_diff(i);
488 }
489 } else if (proto.diff_size() > 0) {
490 CHECK_EQ(count_, proto.diff_size());
491 Dtype* diff_vec = mutable_cpu_diff();
492 for (int i = 0; i < count_; ++i) {
493 diff_vec[i] = proto.diff(i);
494 }
495 }
496}
497
498template <>
499void Blob<double>::ToProto(BlobProto* proto, bool write_diff) const {

Callers 7

DataTransformerMethod · 0.80
CopyTrainedLayersFromMethod · 0.80
DataLayerSetUpMethod · 0.80
LayerSetUpMethod · 0.80
read_meanFunction · 0.80
LayerMethod · 0.80

Calls 8

numMethod · 0.80
shapeMethod · 0.80
dataMethod · 0.80
diffMethod · 0.80
resizeMethod · 0.45
channelsMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected