void GradientChecker<Dtype>::CheckGradientEltwise(Layer<Dtype>* layer,
    const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
  layer->SetUp(bottom, top);
  CHECK_GT(top.size(), 0) << "Eltwise mode requires at least one top blob.";
  const int check_bottom = -1;
  const bool element_wise = true;
  for (int i = 0; i < top.size(); ++i) {
    for (int j = 0; j < top[i]->count(); ++j) {
      CheckGradientSingle(layer, bottom, top, check_bottom, i, j, element_wise);
    }
  }
}
void GradientChecker<Dtype>::CheckGradientExhaustive(Layer<Dtype>& layer,
		vector<Blob<Dtype>*>& bottom, vector<Blob<Dtype>*>& top,
		int check_bottom) {
	layer.SetUp(bottom, &top);
	// LOG(ERROR) << "Exhaustive Mode.";
	for (int i = 0; i < top.size(); ++i) {
		// LOG(ERROR) << "Exhaustive: blob " << i << " size " << top[i]->count();
		for (int j = 0; j < top[i]->count(); ++j) {
			// LOG(ERROR) << "Exhaustive: blob " << i << " data " << j;
			CheckGradientSingle(layer, bottom, top, check_bottom, i, j);
		}
	}
}
void GradientChecker<Dtype>::CheckGradientExhaustive(Layer<Dtype>* layer,
    vector<Blob<Dtype>*>* bottom, vector<Blob<Dtype>*>* top, int check_bottom) {
  layer->SetUp(*bottom, top);
  CHECK_GT(top->size(), 0) << "Exhaustive mode requires at least one top blob.";
  // LOG(ERROR) << "Exhaustive Mode.";
  for (int i = 0; i < top->size(); ++i) {
    // LOG(ERROR) << "Exhaustive: blob " << i << " size " << top[i]->count();
    for (int j = 0; j < (*top)[i]->count(); ++j) {
      // LOG(ERROR) << "Exhaustive: blob " << i << " data " << j;
      CheckGradientSingle(layer, bottom, top, check_bottom, i, j);
    }
  }
}
 // Checks the gradient of a layer, with provided bottom layers and top
 // layers.
 // Note that after the gradient check, we do not guarantee that the data
 // stored in the layer parameters and the blobs are unchanged.
 void CheckGradient(
     Layer<Dtype>* layer,
     const vector<Blob<Dtype>*>& bottom,
     const vector<Blob<Dtype>*>& top,
     int check_bottom = -1) {
     layer->SetUp(
         bottom,
         top);
     CheckGradientSingle(
         layer,
         bottom,
         top,
         check_bottom,
         -1,
         -1);
 }
void GradientChecker<Dtype>::CheckGradientExhaustive(
    Layer<Dtype>* layer,
    const vector<Blob<Dtype>*>& bottom,
    const vector<Blob<Dtype>*>& top,
    int check_bottom) {
    layer->SetUp(
        bottom,
        top);
    CHECK_GT(top.size(), 0)<< "Exhaustive mode requires at least one top blob.";
    for (int i = 0; i < top.size(); ++i) {
        for (int j = 0; j < top[i]->count(); ++j) {
            CheckGradientSingle(
                layer,
                bottom,
                top,
                check_bottom,
                i,
                j);
        }
    }
}