What is the shape of bottom[0]->mutable_gpu_diff()?
When I implement a new layer based on SoftmaxWithLossLayer, there is a segmentation fail in the GPU mode.
The CPU mode is fine.
The code below is the way to access prob_.cpu_data() in CPU mode.
const Dtype* prob_data = prob_.cpu_data();
int dim = prob_.count() / outer_num_;
for (int i = 0; i < outer_num_; ++i) {
loss_mem[i] = Dtype(0);
for (int j = 0; j < inner_num_; j++) {
const int label_value = static_cast<int>(label[i * inner_num_ + j]);
if (has_ignore_label_ && label_value == ignore_label_) {
continue;
}
DCHECK_GE(label_value, 0);
DCHECK_LT(label_value, prob_.shape(softmax_axis_));
loss_tmp = -log(std::max(prob_data[i * dim + label_value * inner_num_ + j], Dtype(FLT_MIN)));
loss += loss_tmp
loss_mem[i] += loss_tmp;
++count;
}
}
I use the same way to access bottom[0]->mutable_gpu_diff(), but the idex seems out of range.
The shape of it may not be the same.
Can anyone help me?
Thank you.