This will revise moco::tf IR and base classes to alias of moco IR and base classes
Signed-off-by: SaeHie Park <saehie.park@samsung.com>
+++ /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 "TFNode.h"
-#include "TFDialect.h"
-
-namespace moco
-{
-namespace tf
-{
-
-const loco::Dialect *TFNode::dialect(void) const { return TFDialect::get(); }
-
-} // namespace tf
-} // namespace moco
#ifndef __MOCO_TF_DIALECT_TFNODE_DECL_H__
#define __MOCO_TF_DIALECT_TFNODE_DECL_H__
-#include <loco/IR/Node.h>
-#include <loco/IR/Dialect.h>
+#include <moco/IR/TFNodeDecl.h>
#include "TFOpcode.h"
-#include "TFNodeVisitor.forward.h"
-
-#include <array>
namespace moco
{
{
/// @note Below alias may be introduced as separate class
-using TFDataLayout = std::string;
-using TFPadding = std::string;
-
-struct TFNode : public loco::Node
-{
- virtual ~TFNode() = default;
-
- const loco::Dialect *dialect(void) const final;
- virtual TFOpcode opcode(void) const = 0;
-
- template <typename T> T accept(TFNodeVisitorBase<T> *) const;
- template <typename T> T accept(TFNodeMutableVisitorBase<T> *);
-};
-
-template <TFOpcode Code> struct TFNodeImpl : public TFNode
-{
- virtual ~TFNodeImpl() = default;
-
- uint32_t opnum(void) const final { return static_cast<uint32_t>(Code); }
- TFOpcode opcode(void) const final { return Code; }
-};
-
-/**
- * @brief Nodes with the fixed number of inputs
- */
-template <unsigned N, typename Base> class FixedArityNode : public Base
-{
-public:
- FixedArityNode()
- {
- for (uint32_t n = 0; n < N; ++n)
- {
- _args[n] = std::unique_ptr<loco::Use>{new loco::Use{this}};
- }
- }
-
- virtual ~FixedArityNode() = default;
-
-public:
- unsigned arity(void) const final { return N; }
-
- loco::Node *arg(uint32_t n) const final { return _args.at(n)->node(); }
+using TFDataLayout = ::moco::TFDataLayout;
+using TFPadding = ::moco::TFPadding;
- void drop(void) final
- {
- for (uint32_t n = 0; n < N; ++n)
- {
- _args.at(n)->node(nullptr);
- }
- }
+using TFNode = ::moco::TFNode;
-protected:
- // This API allows inherited classes to access "_args" field.
- loco::Use *at(unsigned n) const { return _args.at(n).get(); }
+template <TFOpcode Code> using TFNodeImpl = ::moco::TFNodeImpl<Code>;
-private:
- std::array<std::unique_ptr<loco::Use>, N> _args;
-};
+template <unsigned N, typename Base> using FixedArityNode = ::moco::FixedArityNode<N, Base>;
} // namespace tf
} // namespace moco
#include "TFNodes.h"
#include "TFNodeVisitor.h"
-#include <stdexcept>
-
-namespace moco
-{
-namespace tf
-{
-
-template <typename T> T TFNode::accept(TFNodeVisitorBase<T> *v) const
-{
- switch (this->opcode())
- {
-#define TENSORFLOW_NODE(OPCODE, CLASS) \
- case TFOpcode::OPCODE: \
- return v->visit(dynamic_cast<const CLASS *>(this));
-
-#include "TFNodes.lst"
-#undef TENSORFLOW_NODE
- default:
- break;
- }
-
- throw std::runtime_error{"NYI"};
-}
-
-template <typename T> T TFNode::accept(TFNodeMutableVisitorBase<T> *v)
-{
- switch (this->opcode())
- {
-#define TENSORFLOW_NODE(OPCODE, CLASS) \
- case TFOpcode::OPCODE: \
- return v->visit(dynamic_cast<CLASS *>(this));
-
-#include "TFNodes.lst"
-#undef TENSORFLOW_NODE
- default:
- break;
- }
-
- throw std::runtime_error{"NYI"};
-}
-
-} // namespace tf
-} // namespace moco
+#include <moco/IR/TFNodeImpl.h>
#endif // __MOCO_TF_DIALECT_TFNODE_IMPL_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.
- */
-
-#ifndef __MOCO_TF_DIALECT_TFNODE_VISITOR_FORWARD_H__
-#define __MOCO_TF_DIALECT_TFNODE_VISITOR_FORWARD_H__
-
-namespace moco
-{
-namespace tf
-{
-
-// NOTE These forward declarations SHOULD BE aligned with Node delcarations in
-// "TFNodeVisitor.h"
-template <typename T> struct TFNodeVisitorBase;
-template <typename T> struct TFNodeMutableVisitorBase;
-
-} // namespace tf
-} // namespace moco
-
-#endif // __MOCO_TF_DIALECT_TFNODE_VISITOR_FORWARD_H__
#include "TFNodes.h"
-#include <stdexcept>
+#include <moco/IR/TFNodeVisitor.h>
namespace moco
{
namespace tf
{
-/**
- * DO NOT use this class. Use TFNodeVisitor instead.
- */
-template <typename T> struct TFNodeVisitorBase
-{
- virtual ~TFNodeVisitorBase() = default;
-
-#define TENSORFLOW_NODE(OPCODE, CLASS) virtual T visit(const CLASS *) = 0;
-#include "TFNodes.lst"
-#undef TENSORFLOW_NODE
-};
-
-template <typename T> struct TFNodeVisitor : public TFNodeVisitorBase<T>
-{
- virtual ~TFNodeVisitor() = default;
-
-#define TENSORFLOW_NODE(OPCODE, CLASS) \
- virtual T visit(const CLASS *node) { return visit(static_cast<const TFNode *>(node)); }
-#include "TFNodes.lst"
-#undef TENSORFLOW_NODE
-
- /// @brief Default fallback
- virtual T visit(const TFNode *) { throw std::runtime_error{"Not implemented, yet"}; }
-};
-
-/**
- * DO NOT use this class. Use TFNodeMutableVisitor instead.
- */
-template <typename T> struct TFNodeMutableVisitorBase
-{
- virtual ~TFNodeMutableVisitorBase() = default;
-
-#define TENSORFLOW_NODE(OPCODE, CLASS) virtual T visit(CLASS *) = 0;
-#include "TFNodes.lst"
-#undef TENSORFLOW_NODE
-};
-
-template <typename T> struct TFNodeMutableVisitor : public TFNodeMutableVisitorBase<T>
-{
- virtual ~TFNodeMutableVisitor() = default;
-
-#define TENSORFLOW_NODE(OPCODE, CLASS) \
- virtual T visit(CLASS *node) { return visit(static_cast<TFNode *>(node)); }
-#include "TFNodes.lst"
-#undef TENSORFLOW_NODE
+template <typename T> using TFNodeVisitor = ::moco::TFNodeVisitor<T>;
- /// @brief Default fallback
- virtual T visit(TFNode *) { throw std::runtime_error{"Not implemented, yet"}; }
-};
+template <typename T> using TFNodeMutableVisitor = ::moco::TFNodeMutableVisitor<T>;
} // namespace tf
} // namespace moco
#ifndef __MOCO_TF_DIALECT_TFOPCODE_H__
#define __MOCO_TF_DIALECT_TFOPCODE_H__
+#include <moco/IR/TFOpcode.h>
+
namespace moco
{
namespace tf
{
-/**
- * @brief TensorFlow Node Opcode
- */
-enum class TFOpcode
-{
-#define TENSORFLOW_NODE(OPCODE, CLASS) OPCODE,
-#include "TFNodes.lst"
-#undef TENSORFLOW_NODE
-};
+using TFOpcode = ::moco::TFOpcode;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include "moco/IR/Nodes/TFAdd.h"
+
namespace moco
{
namespace tf
{
-/// @note TFAdd corresponds to the following GraphDef
-/*
-node {
- name: "add"
- op: "Add"
- input: "x"
- input: "y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFAdd final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Add>>
-{
-public:
- TFAdd() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-
- Node *y(void) const { return at(1)->node(); }
- void y(Node *node) { at(1)->node(node); }
-};
+using TFAdd = ::moco::TFAdd;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <vector>
+#include <moco/IR/Nodes/TFAvgPool.h>
namespace moco
{
namespace tf
{
-/// @note TFAvgPool corresponds to the following GraphDef
-/*
-node {
- name: "avgpool"
- op: "AvgPool"
- input: "placeholder"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "data_format"
- value {
- s: "NHWC"
- }
- }
- attr {
- key: "ksize"
- value {
- list {
- i: 1 i: 3 i: 3 i: 1
- }
- }
- }
- attr {
- key: "padding"
- value {
- s: "SAME"
- }
- }
- attr {
- key: "strides"
- value {
- list {
- i: 1 i: 1 i: 1 i: 1
- }
- }
- }
-}
-*/
-
-class TFAvgPool final : public FixedArityNode<1, TFNodeImpl<TFOpcode::AvgPool>>
-{
-public:
- TFAvgPool() = 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;
-};
+using TFAvgPool = ::moco::TFAvgPool;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFBiasAdd.h>
+
namespace moco
{
namespace tf
{
-/// @note TFBiasAdd corresponds to the following GraphDef
-/*
-node {
- name: "bias_add_01"
- op: "BiasAdd"
- input: "input_01"
- input: "bias_add_01/bias"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "data_format"
- value {
- s: "NHWC"
- }
- }
-}
-*/
-
-class TFBiasAdd final : public FixedArityNode<2, TFNodeImpl<TFOpcode::BiasAdd>>
-{
-public:
- TFBiasAdd() = default;
-
-public:
- Node *value(void) const { return at(0)->node(); }
- void value(Node *node) { return at(0)->node(node); }
-
- Node *bias(void) const { return at(1)->node(); }
- void bias(Node *node) { return at(1)->node(node); }
-
- const TFDataLayout data_layout(void) const { return _data_layout; }
- void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
-
-private:
- TFDataLayout _data_layout;
-};
+using TFBiasAdd = ::moco::TFBiasAdd;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include "Dialect/VariadicArityNode.h"
+#include <moco/IR/Nodes/TFConcatV2.h>
namespace moco
{
namespace tf
{
-/// @note TFConcatV2 corresponds to the following GraphDef
-/*
-node {
- name: "Concat"
- op: "ConcatV2"
- input: "Input01"
- input: "Input02"
- input: "Axis"
- attr {
- key: "N"
- value {
- i: 2
- }
- }
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tidx"
- value {
- type: DT_INT32
- }
- }
-}
-*/
-
-class TFConcatV2 final : public VariadicArityNode<TFNodeImpl<TFOpcode::ConcatV2>>
-{
-public:
- TFConcatV2(uint32_t arity) : VariadicArityNode<TFNodeImpl<TFOpcode::ConcatV2>>(arity + 1)
- {
- // we add +1 for axis of VariadicArityNode ctor
- // at least one value is required
- assert(arity >= 1);
- }
-
-public:
- uint32_t num_values(void) const
- {
- // last one is for axis
- return arity() - 1;
- }
-
-public:
- Node *values(uint32_t index) const
- {
- assert(index < num_values());
- return at(index)->node();
- }
- void values(uint32_t index, Node *node)
- {
- assert(index < num_values());
- at(index)->node(node);
- }
-
- Node *axis(void) const { return at(num_values())->node(); }
- void axis(Node *node) { at(num_values())->node(node); }
-};
+using TFConcatV2 = ::moco::TFConcatV2;
} // namespace tf
} // namespace moco
+++ /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/TFConst.h"
-
-#include <cassert>
-
-namespace moco
-{
-namespace tf
-{
-
-template <loco::DataType DT> uint32_t TFConst::size(void) const
-{
- assert(dtype() == DT);
- assert(_data.size() % sizeof(typename loco::DataTypeImpl<DT>::Type) == 0);
- return _data.size() / sizeof(typename loco::DataTypeImpl<DT>::Type);
-}
-
-template <loco::DataType DT> void TFConst::size(uint32_t l)
-{
- assert(dtype() == DT);
- _data.resize(l * sizeof(typename loco::DataTypeImpl<DT>::Type));
-}
-
-template <loco::DataType DT>
-const typename loco::DataTypeImpl<DT>::Type &TFConst::at(uint32_t n) const
-{
- assert(dtype() == DT);
- assert(n < size<DT>());
- return *(reinterpret_cast<const typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n);
-}
-
-template <loco::DataType DT> typename loco::DataTypeImpl<DT>::Type &TFConst::at(uint32_t n)
-{
- assert(dtype() == DT);
- assert(n < size<DT>());
- return *(reinterpret_cast<typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n);
-}
-
-#define INSTANTIATE(DT) \
- template uint32_t TFConst::size<DT>(void) const; \
- template void TFConst::size<DT>(uint32_t); \
- template const typename loco::DataTypeImpl<DT>::Type &TFConst::at<DT>(uint32_t) const; \
- template typename loco::DataTypeImpl<DT>::Type &TFConst::at<DT>(uint32_t);
-
-INSTANTIATE(loco::DataType::S32);
-INSTANTIATE(loco::DataType::FLOAT32);
-
-#undef INSTANTIATE
-
-} // namespace tf
-} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <loco/IR/DataTypeTraits.h>
-#include <loco/IR/NodeMixins.h>
-
-#include <vector>
+#include <moco/IR/Nodes/TFConst.h>
namespace moco
{
namespace tf
{
-/// @note TFConst corresponds to the following GraphDef
-/*
-node {
- name: "val"
- op: "Const"
- attr {
- key: "dtype"
- value { type: DT_FLOAT }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim { size: 1 }
- dim { size: 3 }
- dim { size: 4 }
- dim { size: 4 }
- }
- float_val: 2.1
- }
- }
- }
-}
-*/
-
-/**
- * @brief IR for tf.constant
- *
- * @note Implementation for this class came from Canonical ConstGen
- * Read comments in loco::ConstGen for details
- */
-class TFConst final : public FixedArityNode<0, TFNodeImpl<TFOpcode::Const>>,
- public loco::NodeMixin<loco::NodeTrait::DataType>,
- public loco::NodeMixin<loco::NodeTrait::TensorShape>
-{
-public:
- TFConst() = default;
-
-public:
- template <loco::DataType DT> uint32_t size(void) const;
- template <loco::DataType DT> void size(uint32_t size);
-
- template <loco::DataType DT> const typename loco::DataTypeImpl<DT>::Type &at(uint32_t n) const;
- template <loco::DataType DT> typename loco::DataTypeImpl<DT>::Type &at(uint32_t n);
-
-private:
- std::vector<uint8_t> _data;
-};
+using TFConst = ::moco::TFConst;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <vector>
+#include <moco/IR/Nodes/TFConv2D.h>
namespace moco
{
namespace tf
{
-class TFConv2D final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Conv2D>>
-{
-public:
- loco::Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-
- loco::Node *filter(void) const { return at(1)->node(); }
- void filter(Node *node) { at(1)->node(node); }
-
-public:
- const TFPadding &padding(void) const { return _padding; }
- void padding(const TFPadding &padding) { _padding = padding; }
-
- const TFDataLayout &data_layout(void) const { return _data_layout; }
- void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
-
- const std::vector<int64_t> &strides(void) const { return _strides; }
- void strides(const std::vector<int64_t> &strides) { _strides = strides; }
-
-private:
- TFPadding _padding;
- TFDataLayout _data_layout;
- std::vector<int64_t> _strides;
- // TODO Support "Dilation"
-};
+using TFConv2D = ::moco::TFConv2D;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <vector>
+#include <moco/IR/Nodes/TFConv2DBackpropInput.h>
namespace moco
{
namespace tf
{
-/// @note TFConv2DBackpropInput corresponds to the following GraphDef
-/*
-node {
- name: "conv2d_backprop_input"
- op: "Conv2DBackpropInput"
- input: "input_sizes"
- input: "filter"
- input: "out_backprop"
- attr {
- key: "T"
- value { type: DT_FLOAT }
- }
- attr {
- key: "data_format"
- value { s: "NHWC" }
- }
- attr {
- key: "dilations"
- value {
- list { i: 1 i: 1 i: 1 i: 1 }
- }
- }
- attr {
- key: "padding"
- value { s: "SAME" }
- }
- attr {
- key: "strides"
- value {
- list { i: 1 i: 2 i: 2 i: 1 }
- }
- }
-}
-*/
-
-/**
- * @note For Tensorflow Conv2DBackpropInput, 'input' refers actual output of the
- * node, and 'input' refers actual input. The reasone of this is, as name
- * suggests, because it is inspired from backpropagation of convolution.
- * For example, 'out_backprop' of Conv2DBackpropInput is its actual input
- * feature map, and 'input_sizes' means desired output node's size.
- * Note that this convention is against loco canonical's convention.
- */
-class TFConv2DBackpropInput final
- : public FixedArityNode<3, TFNodeImpl<TFOpcode::Conv2DBackpropInput>>
-{
-public:
- loco::Node *input_sizes(void) const { return at(0)->node(); }
- void input_sizes(Node *node) { at(0)->node(node); }
-
- loco::Node *filter(void) const { return at(1)->node(); }
- void filter(Node *node) { at(1)->node(node); }
-
- loco::Node *out_backprop(void) const { return at(2)->node(); }
- void out_backprop(Node *node) { at(2)->node(node); }
-
-public:
- const TFPadding &padding(void) const { return _padding; }
- void padding(const TFPadding &padding) { _padding = padding; }
-
- const TFDataLayout &data_layout(void) const { return _data_layout; }
- void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
-
- const std::vector<int64_t> &strides(void) const { return _strides; }
- void strides(const std::vector<int64_t> &strides) { _strides = strides; }
-
-private:
- TFPadding _padding;
- TFDataLayout _data_layout;
- std::vector<int64_t> _strides;
- // TODO Support "Dilation"
-};
+using TFConv2DBackpropInput = ::moco::TFConv2DBackpropInput;
} // namespace tf
} // namespace moco
#include "Convert.h"
-#include <loco/IR/Stride.h>
-#include <loco/IR/Padding2D.h>
-
-#include <string>
-#include <vector>
+#include <moco/IR/Nodes/TFDepthwiseConv2dNative.h>
namespace moco
{
namespace tf
{
-class TFDepthwiseConv2dNative final
- : public FixedArityNode<2, TFNodeImpl<TFOpcode::DepthwiseConv2dNative>>
-{
-public:
- loco::Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-
- loco::Node *filter(void) const { return at(1)->node(); }
- void filter(Node *node) { at(1)->node(node); }
-
-public:
- const TFPadding &padding(void) const { return _padding; }
- void padding(const TFPadding &padding) { _padding = padding; }
-
- const TFDataLayout &data_layout(void) const { return _data_layout; }
- void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
-
- const std::vector<int64_t> &strides(void) const { return _strides; }
- void strides(const std::vector<int64_t> &strides) { _strides = strides; }
-
-private:
- TFPadding _padding;
- TFDataLayout _data_layout;
- std::vector<int64_t> _strides;
- // TODO Support "Dilation"
-};
+using TFDepthwiseConv2dNative = ::moco::TFDepthwiseConv2dNative;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFFusedBatchNorm.h>
+
namespace moco
{
namespace tf
{
-class TFFusedBatchNorm final : public FixedArityNode<5, TFNodeImpl<TFOpcode::FusedBatchNorm>>
-{
-public:
- TFFusedBatchNorm() = default;
-
-public:
- Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-
- Node *gamma(void) const { return at(1)->node(); }
- void gamma(Node *node) { at(1)->node(node); }
-
- Node *beta(void) const { return at(2)->node(); }
- void beta(Node *node) { at(2)->node(node); }
-
- Node *mean(void) const { return at(3)->node(); }
- void mean(Node *node) { at(3)->node(node); }
-
- Node *variance(void) const { return at(4)->node(); }
- void variance(Node *node) { at(4)->node(node); }
-
- float epsilon(void) const { return _epsilon; }
- void epsilon(float epsilon) { _epsilon = epsilon; }
-
-private:
- float _epsilon = 0.001f;
-};
+using TFFusedBatchNorm = ::moco::TFFusedBatchNorm;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFIdentity.h>
+
namespace moco
{
namespace tf
{
-/// @note TFIdentity corresponds to the following GraphDef
-/*
-node {
- name: "identity"
- op: "Identity"
- input: "Placeholder"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFIdentity final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Identity>>
-{
-public:
- TFIdentity() = default;
-
-public:
- Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-};
+using TFIdentity = ::moco::TFIdentity;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <vector>
+#include <moco/IR/Nodes/TFMaxPool.h>
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 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;
-};
+using TFMaxPool = ::moco::TFMaxPool;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <vector>
+#include <moco/IR/Nodes/TFMean.h>
namespace moco
{
namespace tf
{
-class TFMean final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Mean>>
-{
-public:
- TFMean() = default;
-
-public:
- Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-
- Node *reduction_indices(void) const { return at(1)->node(); }
- void reduction_indices(Node *node) { at(1)->node(node); }
-
-public:
- bool keep_dims(void) const { return _keep_dims; }
- void keep_dims(bool keep_dims) { _keep_dims = keep_dims; }
-
-private:
- bool _keep_dims = false;
-};
+using TFMean = ::moco::TFMean;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFMul.h>
+
namespace moco
{
namespace tf
{
-/// @note TFMul corresponds to the following GraphDef
-/*
-node {
- name: "mul"
- op: "Mul"
- input: "x"
- input: "y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFMul final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Mul>>
-{
-public:
- TFMul() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-
- Node *y(void) const { return at(1)->node(); }
- void y(Node *node) { at(1)->node(node); }
-};
+using TFMul = ::moco::TFMul;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFPad.h>
+
namespace moco
{
namespace tf
{
-/// @note TFPad corresponds to the following GraphDef
-/*
-node {
- name: "Pad"
- op: "Pad"
- input: "Const_tensor"
- input: "Const_paddings"
- attr {
- key: "T"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "Tpaddings"
- value {
- type: DT_INT32
- }
- }
-}
-*/
-
-class TFPad final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Pad>>
-{
-public:
- TFPad() = default;
-
-public:
- Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
- Node *paddings(void) const { return at(1)->node(); }
- void paddings(Node *node) { at(1)->node(node); }
-};
+using TFPad = ::moco::TFPad;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFRealDiv.h>
+
namespace moco
{
namespace tf
{
-/// @note TFRealDiv corresponds to the following GraphDef
-/*
-node {
- name: "div"
- op: "RealDiv"
- input: "x"
- input: "y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFRealDiv final : public FixedArityNode<2, TFNodeImpl<TFOpcode::RealDiv>>
-{
-public:
- TFRealDiv() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-
- Node *y(void) const { return at(1)->node(); }
- void y(Node *node) { at(1)->node(node); }
-};
+using TFRealDiv = ::moco::TFRealDiv;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFRelu.h>
+
namespace moco
{
namespace tf
{
-class TFRelu final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Relu>>
-{
-public:
- TFRelu() = default;
-
-public:
- Node *features(void) const { return at(0)->node(); }
- void features(Node *node) { at(0)->node(node); }
-};
+using TFRelu = ::moco::TFRelu;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFRelu6.h>
+
namespace moco
{
namespace tf
{
-class TFRelu6 final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Relu6>>
-{
-public:
- TFRelu6() = default;
-
-public:
- Node *features(void) const { return at(0)->node(); }
- void features(Node *node) { at(0)->node(node); }
-};
+using TFRelu6 = ::moco::TFRelu6;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFReshape.h>
+
namespace moco
{
namespace tf
{
-/// @note TFReshape corresponds to the following GraphDef
-/*
-node {
- name: "reshape"
- op: "Reshape"
- input: "tensor"
- input: "shape"
- attr {
- key: "T"
- value { type: DT_FLOAT }
- }
-}
-*/
-
-class TFReshape final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Reshape>>
-{
-public:
- TFReshape() = default;
-
-public:
- Node *tensor(void) const { return at(0)->node(); }
- void tensor(Node *node) { at(0)->node(node); }
-
- Node *shape(void) const { return at(1)->node(); }
- void shape(Node *node) { at(1)->node(node); }
-};
+using TFReshape = ::moco::TFReshape;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFRsqrt.h>
+
namespace moco
{
namespace tf
{
-/// @note TFRsqrt corresponds to the following GraphDef
-/*
-node {
- name: "Rsqrt"
- op: "Rsqrt"
- input: "Placeholder"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFRsqrt final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Rsqrt>>
-{
-public:
- TFRsqrt() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-};
+using TFRsqrt = ::moco::TFRsqrt;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <loco/IR/NodeMixins.h>
-
-#include <vector>
+#include <moco/IR/Nodes/TFShape.h>
namespace moco
{
namespace tf
{
-/// @note TFShape corresponds to the following GraphDef
-/*
-node {
- name: "Shape"
- op: "Shape"
- input: "some_input"
- attr {
- key: "T"
- value { type: DT_FLOAT }
- }
- attr {
- key: "out_type"
- value { type: DT_INT32 }
- }
-}
-*/
-
-/// @note Mixed in dtype() is for 'out_type' attribute
-class TFShape final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Shape>>,
- public loco::NodeMixin<loco::NodeTrait::DataType>
-{
-public:
- TFShape() = default;
-
-public:
- Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-};
+using TFShape = ::moco::TFShape;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFSoftmax.h>
+
namespace moco
{
namespace tf
{
-class TFSoftmax final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Softmax>>
-{
-public:
- TFSoftmax() = default;
-
-public:
- Node *logits(void) const { return at(0)->node(); }
- void logits(Node *node) { at(0)->node(node); }
-};
+using TFSoftmax = ::moco::TFSoftmax;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFSqrt.h>
+
namespace moco
{
namespace tf
{
-/// @note TFSqrt corresponds to the following GraphDef
-/*
-node {
- name: "Sqrt"
- op: "Sqrt"
- input: "Placeholder"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFSqrt final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Sqrt>>
-{
-public:
- TFSqrt() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-};
+using TFSqrt = ::moco::TFSqrt;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFSquaredDifference.h>
+
namespace moco
{
namespace tf
{
-/// @note TFSquaredDifference corresponds to the following GraphDef
-/*
-node {
- name: "SquaredDifference"
- op: "SquaredDifference"
- input: "input_x"
- input: "input_y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFSquaredDifference final : public FixedArityNode<2, TFNodeImpl<TFOpcode::SquaredDifference>>
-{
-public:
- TFSquaredDifference() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-
- Node *y(void) const { return at(1)->node(); }
- void y(Node *node) { at(1)->node(node); }
-};
+using TFSquaredDifference = ::moco::TFSquaredDifference;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
-#include <vector>
+#include <moco/IR/Nodes/TFSqueeze.h>
namespace moco
{
namespace tf
{
-/// @note TFSqueeze corresponds to the following GraphDef
-/*
-node {
- name: "squeeze"
- op: "Squeeze"
- input: "x"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "squeeze_dims"
- value {
- list {
- i: a
- i: b
- ..
- }
- }
- }
-}
-*/
-
-class TFSqueeze final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Squeeze>>
-{
-public:
- TFSqueeze() = default;
-
-public:
- Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-
-public:
- const std::vector<int64_t> &squeeze_dims(void) const { return _squeeze_dims; }
- void squeeze_dims(const std::vector<int64_t> &squeeze_dims) { _squeeze_dims = squeeze_dims; }
-
-private:
- std::vector<int64_t> _squeeze_dims;
-};
+using TFSqueeze = ::moco::TFSqueeze;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFStopGradient.h>
+
namespace moco
{
namespace tf
{
-/// @note TFStopGradient corresponds to the following GraphDef
-/*
-node {
- name: "StopGradient"
- op: "StopGradient"
- input: "Placeholder"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFStopGradient final : public FixedArityNode<1, TFNodeImpl<TFOpcode::StopGradient>>
-{
-public:
- TFStopGradient() = default;
-
-public:
- Node *input(void) const { return at(0)->node(); }
- void input(Node *node) { at(0)->node(node); }
-};
+using TFStopGradient = ::moco::TFStopGradient;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFSub.h>
+
namespace moco
{
namespace tf
{
-/// @note TFSub corresponds to the following GraphDef
-/*
-node {
- name: "sub"
- op: "Sub"
- input: "x"
- input: "y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-*/
-
-class TFSub final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Sub>>
-{
-public:
- TFSub() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-
- Node *y(void) const { return at(1)->node(); }
- void y(Node *node) { at(1)->node(node); }
-};
+using TFSub = ::moco::TFSub;
} // namespace tf
} // namespace moco
#include "Dialect/TFNodeDecl.h"
+#include <moco/IR/Nodes/TFTanh.h>
+
namespace moco
{
namespace tf
{
-class TFTanh final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Tanh>>
-{
-public:
- TFTanh() = default;
-
-public:
- Node *x(void) const { return at(0)->node(); }
- void x(Node *node) { at(0)->node(node); }
-};
+using TFTanh = ::moco::TFTanh;
} // namespace tf
} // namespace moco