Reputation: 366
I build my caffe using DEBUG=1
flag. therefore I was able to debug it with gdb.
my debug programs was the mnist example:
gdb --args .build_debug/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt
I set my break point at
./include/caffe/layer.hpp:451
which corresponds to the function:
inline Dtype Layer<Dtype>::Forward(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top)
I was trying to print out the DATA of this BLOB but can't find my way.
what i can get is:
- bottom and top are vector of vvectors.
(gdb) p bottom
$30 = std::vector of length 2, capacity 2 = {0x4c24300, 0x4b12fd0}
(gdb) what bottom
type = const std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > &
(gdb) what bottom[0]
type = std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> >::reference
(gdb) what bottom[0][0]
type = caffe::Blob<float>
- I can find the meta-data of this blob
(gdb) p bottom[0][0]
$42 = {
data_ = {
px = 0x4c23710,
pn = {
pi_ = 0x4c23740
}
},
diff_ = {
px = 0x4c23fc0,
pn = {
pi_ = 0x4c23ff0
}
},
shape_data_ = {
px = 0x4c23f00,
pn = {
pi_ = 0x4c23f30
}
},
shape_ = std::vector of length 2, capacity 2 = {100, 10},
count_ = 1000,
capacity_ = 1000
}
but i failed to get the data. the only thing i can do is
(gdb) p bottom[0][0].data_
$43 = {
px = 0x4c23710,
pn = {
pi_ = 0x4c23740
}
}
(gdb) p bottom[0][0].data_.px[0]
$44 = {
cpu_ptr_ = 0x474fef0,
gpu_ptr_ = 0x0,
size_ = 4000,
head_ = caffe::SyncedMemory::HEAD_AT_CPU,
own_cpu_data_ = true,
cpu_malloc_use_cuda_ = false,
own_gpu_data_ = false,
gpu_device_ = -1
}
How can i print the data_ and diff_ member of this blob?
Upvotes: 3
Views: 796
Reputation: 53
For example:
(gdb) p *((float *)(bottom[1].data_.px)->cpu_ptr_+0)
$15 = 0
or
(gdb) p *((float *)(bottom[1].data_.px)->cpu_ptr_+1)
$16 = 1
And also it needed to replace (float *)
to your actual blob pointer type.
Upvotes: 2