#include "Convert.h"
+#include <cassert>
#include <cpp14/memory.h>
#include <model/DataType.h>
#include "Swizzle.h"
namespace srcn
{
+model::Shape asKernelShape(const model::Shape &shape, kernel::FilterLayout frontend_layout,
+ kernel::FilterLayout backend_layout)
+{
+ assert(shape.rank() == 4);
+ if (frontend_layout == backend_layout)
+ {
+ return model::Shape{shape.dim(0), shape.dim(1), shape.dim(2), shape.dim(3)};
+ }
+ else if (frontend_layout == kernel::FilterLayout::OHWI &&
+ backend_layout == kernel::FilterLayout::HWOI)
+ {
+ return model::Shape{shape.dim(1), shape.dim(2), shape.dim(0), shape.dim(3)};
+ }
+ else if (frontend_layout == kernel::FilterLayout::OHWI &&
+ backend_layout == kernel::FilterLayout::OIHW)
+ {
+ return model::Shape{shape.dim(0), shape.dim(3), shape.dim(1), shape.dim(2)};
+ }
+ else if (frontend_layout == kernel::FilterLayout::OIHW &&
+ backend_layout == kernel::FilterLayout::HWOI)
+ {
+ return model::Shape{shape.dim(2), shape.dim(3), shape.dim(0), shape.dim(1)};
+ }
+ else if (frontend_layout == kernel::FilterLayout::OIHW &&
+ backend_layout == kernel::FilterLayout::OHWI)
+ {
+ return model::Shape{shape.dim(0), shape.dim(2), shape.dim(3), shape.dim(1)};
+ }
+ else
+ {
+ throw std::runtime_error("Not supported FilterLayout");
+ }
+}
+
model::Shape asTensorShape(const model::Shape &shape, model::Layout frontend_layout,
model::Layout backend_layout)
{
#ifndef __NEURUN_BACKEND_SRCN_CONVERT_H__
#define __NEURUN_BACKEND_SRCN_CONVERT_H__
+#include "kernel/OperationUtils.h"
#include <model/Layout.h>
#include <model/Shape.h>
#include <model/TypeInfo.h>
namespace srcn
{
+model::Shape asKernelShape(const model::Shape &shape, kernel::FilterLayout frontend_layout,
+ kernel::FilterLayout backend_layout);
+
model::Shape asTensorShape(const model::Shape &shape, model::Layout frontend_layout,
model::Layout backend_layout);