target_include_directories(${nn_import_common} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_target_properties(${nn_import_common} PROPERTIES POSITION_INDEPENDENT_CODE ON)
+target_link_libraries(${nn_import_common} PRIVATE nncc_core)
+target_link_libraries(${nn_import_common} PRIVATE nnc_plugin_core)
+
add_subdirectory(tflite)
add_subdirectory(caffe)
--- /dev/null
+#include <vector>
+
+#include "shape_helper.h"
+#include "PluginException.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace frontend
+{
+namespace common
+{
+
+Shape &ShapeHelper::cutOffBatchDim(Shape &shape)
+{
+ if (shape.dim(0) != 1)
+ {
+ throw PluginException{"While attempting to cut off tensor batch dimension (first one),"
+ "found that it is not 1. Check the model being imported, if the first"
+ "dimension of the input is not 1, then it might be not batch, and the"
+ "code needs some restructuring"};
+ }
+
+ for (unsigned int i = 0; i < shape.rank() - 1; ++i)
+ {
+ shape.dim(i) = shape.dim(i + 1);
+ }
+ shape.resize(shape.rank() - 1);
+
+ return shape;
+}
+
+} // namespace common
+} // namespace frontend
+} // namespace contrib
+} // namespace nncc
--- /dev/null
+#ifndef NNCC_SHAPE_HELPER_H
+#define NNCC_SHAPE_HELPER_H
+
+#include "nncc/core/ADT/tensor/Shape.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace frontend
+{
+namespace common
+{
+
+using nncc::core::ADT::tensor::Shape;
+
+class ShapeHelper
+{
+public:
+ template<typename Iterable>
+ static Shape createShape(const Iterable &iter, std::size_t);
+
+ static Shape &cutOffBatchDim(Shape &shape);
+};
+
+template<typename Iterable>
+Shape ShapeHelper::createShape(const Iterable &iter, std::size_t size)
+{
+ Shape sh;
+ sh.resize(static_cast<uint32_t>(size));
+
+ unsigned int i = 0;
+ for (auto dim : iter)
+ {
+ sh.dim(i++) = dim;
+ }
+
+ return sh;
+}
+
+} // namespace common
+} // namespace frontend
+} // namespace contrib
+} // namespace nncc
+
+#endif // NNCC_SHAPE_HELPER_H