#include "IR/TFDepthwiseConv2dNative.h"
#include "IR/TFFusedBatchNorm.h"
#include "IR/TFIdentity.h"
+#include "IR/TFMaxPool.h"
#include "IR/TFMul.h"
#include "IR/TFReshape.h"
#include "IR/TFRsqrt.h"
TENSORFLOW_NODE(DepthwiseConv2dNative, TFDepthwiseConv2dNative)
TENSORFLOW_NODE(FusedBatchNorm, TFFusedBatchNorm)
TENSORFLOW_NODE(Identity, TFIdentity)
+TENSORFLOW_NODE(MaxPool, TFMaxPool)
TENSORFLOW_NODE(Mul, TFMul)
TENSORFLOW_NODE(Reshape, TFReshape)
TENSORFLOW_NODE(Rsqrt, TFRsqrt)
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MOCO_TF_IR_TFMAXPOOL_H__
+#define __MOCO_TF_IR_TFMAXPOOL_H__
+
+#include "Dialect/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+namespace tf
+{
+
+/// @note TFMaxPool corresponds to the following GraphDef
+/*
+node {
+ name: "maxpool2d"
+ op: "MaxPool"
+ input: "placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+ attr {
+ key: "data_format"
+ value {
+ s: "NHWC"
+ }
+ }
+ attr {
+ key: "ksize"
+ value {
+ list {
+ i: 1 i: 2 i: 2 i: 1
+ }
+ }
+ }
+ attr {
+ key: "padding"
+ value {
+ s: "VALID"
+ }
+ }
+ attr {
+ key: "strides"
+ value {
+ list {
+ i: 1 i: 1 i: 1 i: 1
+ }
+ }
+ }
+}
+*/
+
+class TFMaxPool final : public loco::FixedArityNode<1, TFNodeImpl<TFOpcode::MaxPool>>
+{
+public:
+ TFMaxPool() = default;
+
+public:
+ Node *value(void) const { return at(0)->node(); }
+ void value(Node *node) { return at(0)->node(node); }
+
+public:
+ const TFDataLayout &data_layout(void) const { return _data_layout; }
+ void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
+
+ const TFPadding &padding(void) const { return _padding; }
+ void padding(const TFPadding &padding) { _padding = padding; }
+
+ const std::vector<int64_t> &ksize(void) const { return _ksize; }
+ void ksize(const std::vector<int64_t> &ksize) { _ksize = ksize; }
+
+ const std::vector<int64_t> &strides(void) const { return _strides; }
+ void strides(const std::vector<int64_t> &strides) { _strides = strides; }
+
+private:
+ TFDataLayout _data_layout;
+ TFPadding _padding;
+ std::vector<int64_t> _ksize;
+ std::vector<int64_t> _strides;
+};
+
+} // namespace tf
+} // namespace moco
+
+#endif // __MOCO_TF_IR_TFMAXPOOL_H__
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "IR/TFMaxPool.h"
+
+#include "Dialect/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFMaxPoolTest, constructor)
+{
+ moco::tf::TFMaxPool maxpool;
+
+ ASSERT_EQ(maxpool.dialect(), moco::tf::TFDialect::get());
+ ASSERT_EQ(maxpool.opcode(), moco::tf::TFOpcode::MaxPool);
+
+ ASSERT_EQ(maxpool.value(), nullptr);
+ ASSERT_EQ(maxpool.data_layout(), "");
+ ASSERT_EQ(maxpool.padding(), "");
+ ASSERT_EQ(maxpool.ksize(), std::vector<int64_t>({}));
+ ASSERT_EQ(maxpool.strides(), std::vector<int64_t>({}));
+}
return false;
}
+bool fix_padding(moco::tf::TFMaxPool *node)
+{
+ // TODO implement
+ throw std::runtime_error("NYI fix_padding TFMaxPool");
+}
+
bool fix_padding(moco::tf::TFMul *node)
{
// Nothing to do with padding
return copy_shapedata(input, node);
}
+bool fix_shape(moco::tf::TFMaxPool *node)
+{
+ // TODO implement
+ throw std::runtime_error("NYI fix_shape TFMaxPool");
+}
+
bool fix_shape(moco::tf::TFMul *node)
{
auto x = node->x();