This commit enclosed codes with `namespace exo`.
Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
#include "ExporterUtils.h"
+namespace exo
+{
+
ShapeDescription to_shape_description(const loco::TensorShape &shape)
{
ShapeDescription res;
assert(node->annot<TFLTensorIndexAnnotation>() != nullptr);
return node->annot<TFLTensorIndexAnnotation>()->index();
}
+
+} // namespace exo
#include <unordered_map>
+namespace exo
+{
+
struct OpCode
{
tflite::BuiltinOperator opcode;
bool operator==(const OpCode &rhs) const { return opcode == rhs.opcode; }
};
+} // namespace exo
+
namespace std
{
-template <> struct hash<OpCode>
+template <> struct hash<exo::OpCode>
{
- size_t operator()(const OpCode &x) const { return hash<int>()(x.opcode); }
+ size_t operator()(const exo::OpCode &x) const { return hash<int>()(x.opcode); }
};
} // namespace std
+namespace exo
+{
+
struct ShapeDescription
{
std::vector<int32_t> _dims;
void set_tensor_index(loco::Node *node, const TFLTensorIndex &tensor_id);
TFLTensorIndex get_tensor_index(loco::Node *node);
+} // namespace exo
+
#endif // __EXPORTER_UTILS_H__
namespace
{
+using namespace exo;
+
class OperationExporter final : public locoex::TFLNodeMutableVisitor<void>,
public loco::CanonicalNodeMutableVisitor<void>
{
} // namespace
+namespace exo
+{
+
void exportNodes(loco::Graph *g, FlatBufferBuilder &builder, SerializedModelData &gd)
{
for (auto node : loco::postorder_traversal(loco::output_nodes(g)))
exportNode(node, builder, gd);
}
}
+
+} // namespace exo
#include <loco/IR/Graph.h>
+namespace exo
+{
+
/**
* @brief create Operators corresponding to model nodes
* @param nodes container with nodes
*/
void exportNodes(loco::Graph *g, flatbuffers::FlatBufferBuilder &builder, SerializedModelData &gd);
+} // namespace exo
+
#endif // __OPERATION_EXPORTER_H__
#include <locoex/COpDialect.h>
#include <locoex/Service/COpShapeInferenceRule.h>
+namespace exo
+{
+
void ShapeInference::run(loco::Graph *g)
{
// TODO Adjust indentation level
return to_shape_description(loco::shape_get(node));
}
}
+
+} // namespace exo
#include <loco/IR/Nodes.h>
+namespace exo
+{
+
/**
* @brief Annotate the shape of each node as a node annotation
*
static ShapeDescription get(loco::Node *node);
};
+} // namespace exo
+
#endif // __SHAPE_INFERENCE_H__
namespace
{
+using namespace exo;
+
void registerGraphInputTensors(loco::Graph *graph, SubGraphContext &ctx)
{
for (uint32_t n = 0; n < graph->inputs()->size(); ++n)
return builder.CreateVector(operator_codes_vec);
}
-flatbuffers::Offset<tflite::SubGraph> TFLExporter::Impl::exportSubgraph(SerializedModelData &gd)
+::flatbuffers::Offset<::tflite::SubGraph> TFLExporter::Impl::exportSubgraph(SerializedModelData &gd)
{
auto tensors = _builder.CreateVector(gd._tensors);
auto inputs = _builder.CreateVector(gd._inputs);
#include <loco.h>
-struct SerializedModelData;
-
namespace exo
{
+struct SerializedModelData;
+
/**
* internal implementation of interface exporter class
*/
flatbuffers::FlatBufferBuilder _builder;
};
-} // namespace loco_exporter
+} // namespace exo
#endif // __TFL_EXPORTER_IMPL_H__
namespace
{
+using namespace exo;
+
class TFLTensorInfo
{
public:
} // namespace
+namespace exo
+{
+
void exportOpDefinedTensor(const TFLTensorInfo &info, FlatBufferBuilder &builder,
SerializedModelData &gd)
{
exportOpDefinedTensor(tensor_info, builder, gd);
}
}
+
+} // namespace exo
#include <flatbuffers/flatbuffers.h>
+namespace exo
+{
+
/**
* @brief create Tensors corresponding to results of all nodes in graph
* @param computational graph
void exportOpDefinedTensors(loco::Graph *g, flatbuffers::FlatBufferBuilder &builder,
SerializedModelData &gd);
+} // namespace exo
+
#endif // __TENSOR_EXPORTER_H__
} // namespace
+namespace exo
+{
+
void TypeInference::run(loco::Graph *g)
{
loco::CanonicalTypeInferenceRule canonical_rule;
assert(loco::dtype_known(node));
return translateLocoTypeToTFLite(loco::dtype_get(node));
}
+
+} // namespace exo
#include <loco/IR/Nodes.h>
+namespace exo
+{
+
/**
* @brief Annotate the type of each node as NodeAnnotation
*
static tflite::TensorType get(loco::Node *node);
};
+} // namespace exo
+
#endif // __TYPE_INFERENCE_H__
auto relu = addReLULayer();
auto push = addPushLayer();
+ using namespace exo;
+
TypeInference::run(graph());
ASSERT_EQ(TypeInference::get(relu), tflite::TensorType_INT8);