public:
void visit(const ::internal::tflite::op::Conv2D::implicit::Node &node) override;
+ void visit(const ::internal::tflite::op::MaxPool2D::implicit::Node &node) override;
private:
const ::internal::tflite::operand::Set &_ctx;
_builder.addStage(stage);
}
+void Planner::visit(const ::internal::tflite::op::MaxPool2D::implicit::Node &node)
+{
+ throw std::runtime_error{"Not supported, yet"};
+}
+
class AllocationContext final : public IAllocationContext
{
public:
{
namespace tflite
{
+namespace op
+{
+namespace MaxPool2D
+{
+namespace implicit
+{
+
+void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+} // namespace implicit
+} // namespace Conv2D
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace MaxPool2D
+{
+namespace implicit
+{
+
+Param::Param(uint32_t inputCount, const uint32_t* inputs,
+ uint32_t outputCount, const uint32_t* outputs)
+{
+ assert(inputCount == 7 && outputCount == 1);
+
+ ofm_index = outputs[0];
+
+ // Each input should be interpreted as follows:
+ //
+ // 0 -> IFM Tensor Index
+ // 1 -> Padding Code (ANEURALNETWORKS_PADDING_SAME or ANEURALNETWORKS_PADDING_VALID) Index
+ // 2 -> Horizontal (over width) Stride Index
+ // 3 -> Vertial (over height) Stride Index
+ // 4 -> Filter Width Index
+ // 5 -> Filter Height Index
+ // 6 -> FuseCode (activation) Index
+ ifm_index = inputs[0];
+ padding_index = inputs[1];
+ hstride_index = inputs[2];
+ vstride_index = inputs[3];
+ kw_index = inputs[4];
+ kh_index = inputs[5];
+ activation_index = inputs[6];
+}
+
+} // namespace implicit
+} // namespace Conv2D
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+namespace internal
+{
+namespace tflite
+{
namespace operand
{
{
namespace op
{
+namespace MaxPool2D
+{
+namespace implicit
+{
+
+struct Param
+{
+ int32_t ofm_index;
+
+ int32_t ifm_index;
+
+ int32_t kw_index;
+ int32_t kh_index;
+
+ int32_t hstride_index;
+ int32_t vstride_index;
+
+ int32_t padding_index;
+ int32_t activation_index;
+
+ Param() = default;
+ Param(uint32_t inputCount, const uint32_t* inputs,
+ uint32_t outputCount, const uint32_t* outputs);
+};
+
+class Node final : public op::Node
+{
+public:
+ Node(const Param ¶m) : _param(param)
+ {
+ // DO NOTHING
+ }
+
+public:
+ virtual ~Node() = default;
+
+public:
+ const Param ¶m(void) const { return _param; }
+
+public:
+ void accept(NodeVisitor &&) const override;
+
+private:
+ const Param _param;
+};
+
+} // namespace implicit
+} // namespace MaxPool2D
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
struct NodeVisitor
{
virtual ~NodeVisitor() = default;
virtual void visit(const Conv2D::implicit::Node &) = 0;
+ virtual void visit(const MaxPool2D::implicit::Node &) = 0;
};
} // namespace op
break;
}
+ case ANEURALNETWORKS_MAX_POOL_2D:
+ {
+ // inputCount is either 7 or 9 acccording to NN API specification.
+ // - Padding is implicit when inputCount is 7
+ // - Padding is explicit when inputCount is 9
+ assert(inputCount == 7 || inputCount == 9);
+ assert(outputCount == 1);
+
+ if (inputCount == 7)
+ {
+ using internal::tflite::op::MaxPool2D::implicit::Param;
+ using internal::tflite::op::MaxPool2D::implicit::Node;
+
+ // Add 'operations'
+ auto &operations = model->deref().operations();
+
+ operations.emplace_back<Node>(Param{inputCount, inputs, outputCount, outputs});
+ }
+ else
+ {
+ throw std::runtime_error{"Explicit padding in MaxPool2D is not supported, yet"};
+ }
+ }
default:
throw std::runtime_error{"Not supported operation"};
};