template <typename T> class View final : public Reader<T>, public Accessor<T>
{
public:
- explicit View(const Shape &shape, std::unique_ptr<Layout> &&layout,
+ explicit View(const Shape &shape, const Layout &layout,
std::unique_ptr<nncc::foundation::Region<T>> &®ion)
: _shape{shape}, _layout{std::move(layout)}, _region{std::move(region)}
{
public:
T at(const Index &index) const override
{
- return *(_region->base() + _layout->offset(_shape, index));
+ return *(_region->base() + _layout.offset(_shape, index));
}
public:
- T &at(const Index &index) override { return *(_region->base() + _layout->offset(_shape, index)); }
+ T &at(const Index &index) override { return *(_region->base() + _layout.offset(_shape, index)); }
public:
const Shape &shape(void) const { return _shape; }
private:
const Shape _shape;
- std::unique_ptr<Layout> _layout;
+ const Layout _layout;
private:
std::unique_ptr<nncc::foundation::Region<T>> _region;
template <typename T, typename LayoutImpl>
View<T> make_view(const Shape &shape, std::unique_ptr<nncc::foundation::Region<T>> &®ion)
{
- std::unique_ptr<Layout> layout(new LayoutImpl{});
- return View<T>{shape, std::move(layout), std::move(region)};
+ return View<T>{shape, LayoutImpl{}, std::move(region)};
}
} // namespace tensor