#include "coco/IR/Bag.h"
#include "coco/IR/Object.h"
#include "coco/IR/FeatureLayouts.h"
+#include "coco/IR/KernelLayouts.h"
#include "coco/IR/Op.h"
#include "coco/IR/Instr.h"
+++ /dev/null
-/*
- * Copyright (c) 2018 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 __COCO_IR_GENERIC_KERNEL_LAYOUT_H__
-#define __COCO_IR_GENERIC_KERNEL_LAYOUT_H__
-
-#include "coco/IR/KernelLayout.h"
-
-#include <nncc/core/ADT/kernel/Layout.h>
-
-#include <vector>
-#include <memory>
-
-namespace coco
-{
-
-class GenericKernelLayout final : public KernelLayout
-{
-private:
- GenericKernelLayout(const nncc::core::ADT::kernel::Shape &shape);
-
-public:
- static const KernelLayout::ID *uid(void);
- const KernelLayout::ID *id(void) const override { return uid(); }
-
- const nncc::core::ADT::kernel::Shape &shape(void) const override { return _shape; }
-
- ElemID &at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col);
- ElemID at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const override;
-
- void reorder(const nncc::core::ADT::kernel::Layout &l);
- template <typename LayoutImpl> void reorder(void) { reorder(LayoutImpl{}); }
-
-private:
- nncc::core::ADT::kernel::Shape _shape;
-
-private:
- std::vector<ElemID> _content;
-
-public:
- static std::unique_ptr<GenericKernelLayout> create(const nncc::core::ADT::kernel::Shape &shape);
-};
-
-} // namespace coco
-
-#endif // __COCO_IR_GENERIC_KERNEL_LAYOUT_H__
#include "coco/IR/KernelLayout.h"
+#include <nncc/core/ADT/kernel/Layout.h>
+
+#include <vector>
#include <memory>
namespace coco
static std::unique_ptr<NHWC> create(const nncc::core::ADT::kernel::Shape &shape);
};
+/**
+ * @brief Generic Kernel Layout
+ */
+class Generic final : public KernelLayout
+{
+private:
+ Generic(const nncc::core::ADT::kernel::Shape &shape);
+
+public:
+ static const KernelLayout::ID *uid(void);
+ const KernelLayout::ID *id(void) const override { return uid(); }
+
+ const nncc::core::ADT::kernel::Shape &shape(void) const override { return _shape; }
+
+ ElemID &at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col);
+ ElemID at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const override;
+
+ void reorder(const nncc::core::ADT::kernel::Layout &l);
+ template <typename LayoutImpl> void reorder(void) { reorder(LayoutImpl{}); }
+
+private:
+ nncc::core::ADT::kernel::Shape _shape;
+
+private:
+ std::vector<ElemID> _content;
+
+public:
+ static std::unique_ptr<Generic> create(const nncc::core::ADT::kernel::Shape &shape);
+};
+
} // namespace KernelLayouts
} // namespace coco
#define __COCO_IR_KERNEL_OBJECT_H__
#include "coco/IR/Object.h"
-#include "coco/IR/GenericKernelLayout.h"
+#include "coco/IR/KernelLayout.h"
#include "coco/IR/ElemID.h"
#include <nncc/core/ADT/kernel/Shape.h>
const nncc::core::ADT::kernel::Shape ker_shape{1, 1, 3, 3};
auto ker_bag = m->entity()->bag()->create(num_elements(ker_shape));
- auto ker_layout = coco::GenericKernelLayout::create(ker_shape);
+ auto ker_layout = coco::KernelLayouts::Generic::create(ker_shape);
ker_layout->reorder<NCHWLayout>();
+++ /dev/null
-/*
- * Copyright (c) 2018 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 "coco/IR/GenericKernelLayout.h"
-
-#include <nncc/core/ADT/kernel/NCHWLayout.h>
-
-#include <cassert>
-
-using nncc::core::ADT::kernel::num_elements;
-using nncc::core::ADT::kernel::Shape;
-
-namespace
-{
-
-nncc::core::ADT::kernel::NCHWLayout l;
-
-} // namespace
-
-namespace coco
-{
-
-GenericKernelLayout::GenericKernelLayout(const nncc::core::ADT::kernel::Shape &shape)
- : _shape{shape}
-{
- _content.resize(num_elements(_shape));
-}
-
-const KernelLayout::ID *GenericKernelLayout::uid(void)
-{
- struct LayoutID final : public KernelLayout::ID
- {
- };
- static LayoutID id;
- return &id;
-}
-
-ElemID &GenericKernelLayout::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col)
-{
- return _content.at(l.offset(_shape, n, ch, row, col));
-}
-
-ElemID GenericKernelLayout::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const
-{
- return _content.at(l.offset(_shape, n, ch, row, col));
-}
-
-void GenericKernelLayout::reorder(const nncc::core::ADT::kernel::Layout &l)
-{
- for (uint32_t n = 0; n < shape().count(); ++n)
- {
- for (uint32_t ch = 0; ch < shape().depth(); ++ch)
- {
- for (uint32_t row = 0; row < shape().height(); ++row)
- {
- for (uint32_t col = 0; col < shape().width(); ++col)
- {
- at(n, ch, row, col) = ElemID{l.offset(shape(), n, ch, row, col)};
- }
- }
- }
- }
-}
-
-std::unique_ptr<GenericKernelLayout> GenericKernelLayout::create(const Shape &shape)
-{
- return std::unique_ptr<GenericKernelLayout>{new GenericKernelLayout{shape}};
-}
-
-} // namespace coco
using namespace nncc::core::ADT::kernel;
+using nncc::core::ADT::kernel::num_elements;
+using nncc::core::ADT::kernel::Shape;
+
//
// NCHW Layout
//
} // namespace KernelLayouts
} // namespace coco
+
+//
+// Generic Layout
+//
+namespace
+{
+
+nncc::core::ADT::kernel::NCHWLayout l;
+
+} // namespace
+
+namespace coco
+{
+namespace KernelLayouts
+{
+
+Generic::Generic(const nncc::core::ADT::kernel::Shape &shape) : _shape{shape}
+{
+ _content.resize(num_elements(_shape));
+}
+
+const KernelLayout::ID *Generic::uid(void)
+{
+ struct LayoutID final : public KernelLayout::ID
+ {
+ };
+ static LayoutID id;
+ return &id;
+}
+
+ElemID &Generic::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col)
+{
+ return _content.at(l.offset(_shape, n, ch, row, col));
+}
+
+ElemID Generic::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const
+{
+ return _content.at(l.offset(_shape, n, ch, row, col));
+}
+
+void Generic::reorder(const nncc::core::ADT::kernel::Layout &l)
+{
+ for (uint32_t n = 0; n < shape().count(); ++n)
+ {
+ for (uint32_t ch = 0; ch < shape().depth(); ++ch)
+ {
+ for (uint32_t row = 0; row < shape().height(); ++row)
+ {
+ for (uint32_t col = 0; col < shape().width(); ++col)
+ {
+ at(n, ch, row, col) = ElemID{l.offset(shape(), n, ch, row, col)};
+ }
+ }
+ }
+ }
+}
+
+std::unique_ptr<Generic> Generic::create(const Shape &shape)
+{
+ return std::unique_ptr<Generic>{new Generic{shape}};
+}
+
+} // namespace KernelLayouts
+} // namespace coco
*/
#include "coco/IR/KernelObject.h"
+#include "coco/IR/KernelLayouts.h"
#include <nncc/core/ADT/kernel/NCHWLayout.h>
#include <nncc/foundation/Memory.h>
KernelObject::KernelObject(const nncc::core::ADT::kernel::Shape &shape)
{
- _layout = GenericKernelLayout::create(shape);
+ _layout = KernelLayouts::Generic::create(shape);
}
KernelObject::~KernelObject()