2022-05-30 19:57:50 +08:00
|
|
|
/****************************************************************************
|
|
|
|
|
*
|
2023-01-20 11:38:21 +08:00
|
|
|
* Copyright (c) 2020-2023 Vivante Corporation
|
2022-05-30 19:57:50 +08:00
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
#ifndef TIM_VX_OPS_ROI_POOL_H_
|
|
|
|
|
#define TIM_VX_OPS_ROI_POOL_H_
|
|
|
|
|
|
|
|
|
|
#include <array>
|
2022-09-14 15:20:57 +08:00
|
|
|
#include "tim/vx/builtin_op.h"
|
2022-05-30 19:57:50 +08:00
|
|
|
#include "tim/vx/types.h"
|
|
|
|
|
|
|
|
|
|
namespace tim {
|
|
|
|
|
namespace vx {
|
|
|
|
|
namespace ops {
|
|
|
|
|
|
|
|
|
|
/**
|
2022-07-29 11:10:25 +08:00
|
|
|
* ## RoiPool
|
2022-05-30 19:57:50 +08:00
|
|
|
*
|
|
|
|
|
* Select and scale the feature map of each region of interest to a unified output
|
|
|
|
|
* size by max-pooling.
|
2023-07-08 23:39:56 +08:00
|
|
|
*
|
2022-05-30 19:57:50 +08:00
|
|
|
* pool_type : only support max-pooling (MAX)
|
2023-07-08 23:39:56 +08:00
|
|
|
* scale : The ratio of image to feature map (Range: 0 < scale <= 1)
|
2022-05-30 19:57:50 +08:00
|
|
|
* size : The size of roi pooling (height/width)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2022-09-14 15:20:57 +08:00
|
|
|
class RoiPool : public BuiltinOp {
|
2022-05-30 19:57:50 +08:00
|
|
|
public:
|
2023-07-08 23:39:56 +08:00
|
|
|
RoiPool(Graph* graph, PoolType type, float scale, const std::array<uint32_t, 2>& size,
|
|
|
|
|
DataLayout input_layout = DataLayout::WHCN);
|
2022-05-30 19:57:50 +08:00
|
|
|
|
|
|
|
|
std::shared_ptr<Operation> Clone(
|
|
|
|
|
std::shared_ptr<Graph>& graph) const override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
const PoolType type_;
|
|
|
|
|
const float scale_;
|
|
|
|
|
std::array<uint32_t, 2> size_;
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-29 11:10:25 +08:00
|
|
|
using ROI_Pool = RoiPool;
|
|
|
|
|
|
2022-05-30 19:57:50 +08:00
|
|
|
} // namespace ops
|
|
|
|
|
} // namespace vx
|
|
|
|
|
} // namespace tim
|
|
|
|
|
|
|
|
|
|
#endif /* TIM_VX_OPS_ROI_POOL_H_ */
|