const nncc::core::ADT::feature::Shape &shape(void) const;
public:
- ElemID &at(uint32_t ch, uint32_t row, uint32_t col);
ElemID at(uint32_t ch, uint32_t row, uint32_t col) const;
public:
- void reorder(const nncc::core::ADT::feature::Layout &l);
- template <typename LayoutImpl> void reorder(void) { reorder(LayoutImpl{}); }
-
-public:
const GenericFeatureLayout *layout(void) const { return _layout.get(); }
void layout(std::unique_ptr<GenericFeatureLayout> &&l) { _layout = std::move(l); }
#include <nncc/core/ADT/kernel/NCHWLayout.h>
+#include <nncc/foundation/Memory.h>
+
#include <gtest/gtest.h>
#include <set>
using nncc::core::ADT::tensor::IndexEnumerator;
using nncc::core::ADT::tensor::num_elements;
+using nncc::foundation::make_unique;
+
//
// 'caffe_conv' test demonstrates how to translate the following Caffe network into coco IR:
//
const nncc::core::ADT::feature::Shape ifm_shape{1, 3, 3};
auto ifm_bag = bags["data"];
auto ifm_obj = m->entity()->object()->create(ifm_shape);
+ auto ifm_layout = make_unique<coco::GenericFeatureLayout>(ifm_shape);
+
+ ifm_layout->reorder(CHWLayout{});
ifm_obj->bag(ifm_bag);
- ifm_obj->reorder<CHWLayout>();
+ ifm_obj->layout(std::move(ifm_layout));
const nncc::core::ADT::kernel::Shape ker_shape{1, 1, 3, 3};
auto ker_bag = m->entity()->bag()->create(num_elements(ker_shape));
const nncc::core::ADT::feature::Shape ofm_shape{1, 1, 1};
auto ofm_bag = m->entity()->bag()->create(1 * 1 * 1);
auto ofm_obj = m->entity()->object()->create(ofm_shape);
+ auto ofm_layout = make_unique<coco::GenericFeatureLayout>(ifm_shape);
+
+ ofm_layout->reorder(CHWLayout{});
ofm_obj->bag(ofm_bag);
- ofm_obj->reorder<CHWLayout>();
+ ofm_obj->layout(std::move(ofm_layout));
// Create Conv2D operation
//
const nncc::core::ADT::feature::Shape &FeatureObject::shape(void) const { return _info->shape(); }
-ElemID &FeatureObject::at(uint32_t ch, uint32_t row, uint32_t col)
-{
- assert(_layout->batch() == 1);
- return _layout->at(0, ch, row, col);
-}
-
ElemID FeatureObject::at(uint32_t ch, uint32_t row, uint32_t col) const
{
assert(_layout->batch() == 1);
return _layout->at(0, ch, row, col);
}
-void FeatureObject::reorder(const nncc::core::ADT::feature::Layout &l) { _layout->reorder(l); }
-
} // namespace coco