#include "misc/kernel/Shape.h"
#include "misc/matrix/Shape.h"
#include "misc/tensor/Shape.h"
+#include "graph/operand/Layout.h"
namespace neurun
{
{
using FeatureShape = nnfw::misc::feature::Shape;
+// TODO move graph::operand::Layout definition to neurun::model::Layout
+using Layout = graph::operand::Layout;
struct Shape : public nnfw::misc::tensor::Shape
{
public:
int32_t asVector(void) const;
nnfw::misc::matrix::Shape asMatrix(void) const;
- FeatureShape asFeature(void) const;
- nnfw::misc::kernel::Shape asKernel(void) const;
+ FeatureShape asFeature(const Layout layout = Layout::NHWC) const;
+ nnfw::misc::kernel::Shape asKernel(const Layout layout = Layout::NHWC) const;
nnfw::misc::tensor::Shape asTensor(void) const;
public:
#include <cassert>
#include "model/Shape.h"
+#include "util/Utils.h"
namespace neurun
{
return nnfw::misc::matrix::Shape(height, width);
}
-FeatureShape Shape::asFeature(void) const
+FeatureShape Shape::asFeature(const Layout layout) const
{
assert(rank() == 4);
+ // Handle NHWC only
+ assert(layout == Layout::NHWC);
+ UNUSED_RELEASE(layout);
- // Feature Map in NNAPI
+ // Feature Map in NHWC layout
// - Dimension(0) -> Batch
// - Dimension(1) -> Height
// - Dimension(2) -> Width
return FeatureShape(batch, depth, height, width);
}
-nnfw::misc::kernel::Shape Shape::asKernel(void) const
+nnfw::misc::kernel::Shape Shape::asKernel(const Layout layout) const
{
assert(rank() == 4);
+ // Handle NHWC only
+ assert(layout == Layout::NHWC);
+ UNUSED_RELEASE(layout);
- // Convolution Kernel in NNAPI
+ // Convolution Kernel in NHWC (OHWI) layout
// - Dimension(0) -> Count
// - Dimension(1) -> Height
// - Dimension(2) -> Width