text: // ------------------------------------------------------------------
  // Fast R-CNN
  // Copyright (c) 2015 Microsoft
  // Licensed under The MIT License [see fast-rcnn/LICENSE for details]
  // Written by Ross Girshick
  // ------------------------------------------------------------------
  
  #ifndef CAFFE_ROI_MASK_POOLING_LAYER_HPP_
  #define CAFFE_ROI_MASK_POOLING_LAYER_HPP_
  #include <vector>
  
  #include "caffe/blob.hpp"
  #include "caffe/common.hpp"
  #include "caffe/layer.hpp"
  #include "caffe/proto/caffe.pb.h"
  
  namespace caffe {
  /* ROIMaskPoolingLayer - Region of Interest Pooling Layer With Mask
  */
  template <typename Dtype>
  class ROIMaskPoolingLayer : public Layer<Dtype> {
   public:
    explicit ROIMaskPoolingLayer(const LayerParameter& param)
        : Layer<Dtype>(param) {}
    virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
        const vector<Blob<Dtype>*>& top);
    virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
        const vector<Blob<Dtype>*>& top);
  
    virtual inline const char* type() const { return "ROIMaskPooling"; }
  
    virtual inline int MinBottomBlobs() const { return 2; }
    virtual inline int MaxBottomBlobs() const { return 2; }
    virtual inline int MinTopBlobs() const { return 1; }
    virtual inline int MaxTopBlobs() const { return 1; }
  
   protected:
    virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
        const vector<Blob<Dtype>*>& top);
    virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
        const vector<Blob<Dtype>*>& top);
    virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
        const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
    virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
        const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
  
    int channels_;
    int height_;
    int width_;
    int pooled_height_;
    int pooled_width_;
    Dtype spatial_scale_;
    Dtype spatial_shift_;
    int half_part_;
    Dtype roi_scale_;
    Dtype mask_scale_;
  
    Blob<int> max_idx_;
  };
  
  }  // namespace caffe
  
  #endif  // CAFFE_ROI_MASK_POOLING_LAYER_HPP_
  