23 #ifndef FTL_TENSOR_CONTAINER_HPP
24 #define FTL_TENSOR_CONTAINER_HPP
26 #include <nano/nano.hpp>
41 template <
typename Dtype,
size_t... Sizes>
45 template <
typename Dtype,
size_t SizeFirst,
size_t... SizeRest>
50 using dimension_sizes = nano::list<nano::size_t<SizeFirst>, nano::size_t<SizeRest>...>;
53 using dim_container =
typename nano::runtime_converter<dimension_sizes>::array_type;
54 using size_type =
typename data_container::size_type;
55 using iterator =
typename data_container::iterator;
75 template <
typename... TR>
77 : _data{{std::forward<TR>(values)...}} {}
83 constexpr
size_t size()
const {
return dimension_product::result; }
90 inline data_type& operator[](
size_t i) {
return _data[i]; }
97 inline const data_type& operator[](
size_t i)
const {
return _data[i]; }
103 iterator begin() {
return _data.begin(); }
109 iterator end() {
return _data.end(); }
116 template <
typename Dtype>
117 class TensorContainer<Dtype> {
124 using iterator =
typename data_container::iterator;
137 : _size(data.size()), _data(data){}
143 inline size_t size()
const {
return _size; }
171 data_container _data;
177 #endif // FTL_TENSOR_CONTAINER_HPP
typename data_container::size_type size_type
Definition: tensor_container.hpp:122
TensorContainer()
Default constructor.
Definition: tensor_container.hpp:130
typename data_container::iterator iterator
Definition: tensor_container.hpp:55
iterator begin()
Returns an iterator to the first element of the container.
Definition: tensor_container.hpp:163
typename data_container::iterator iterator
Definition: tensor_container.hpp:124
std::vector< size_type > dim_container
Definition: tensor_container.hpp:123
size_t size() const
Gets the size (total number of elements) in the container.
Definition: tensor_container.hpp:143
Container for tensor data depending on if the tensor is static (dimension sizes, and hence the total ...
Definition: tensor_container.hpp:42
Dtype data_type
Definition: tensor_container.hpp:120
Definition: mapper.hpp:37
nano::multiplies< dimension_sizes > dimension_product
Definition: tensor_container.hpp:51
iterator end()
Returns an iterator to the element following the last element.
Definition: tensor_container.hpp:169
TensorContainer()
Default constructor.
Definition: tensor_container.hpp:61
typename nano::runtime_converter< dimension_sizes >::array_type dim_container
Definition: tensor_container.hpp:53
constexpr TensorContainer(data_container &data)
Contructor when given an array with the data for the container.
Definition: tensor_container.hpp:67
data_type & operator[](size_t i)
Gets an element from the container.
Definition: tensor_container.hpp:150
typename data_container::size_type size_type
Definition: tensor_container.hpp:54
nano::list< nano::size_t< SizeFirst >, nano::size_t< SizeRest >...> dimension_sizes
Definition: tensor_container.hpp:50
std::array< data_type, dimension_product::result > data_container
Definition: tensor_container.hpp:52
TensorContainer(data_container &data)
Contructor when given an array with the data for the container.
Definition: tensor_container.hpp:136
const data_type & operator[](size_t i) const
Gets an element from the container.
Definition: tensor_container.hpp:157
constexpr TensorContainer(TR &&...values)
Move constructor for when the data is given as a literal list.
Definition: tensor_container.hpp:76
std::vector< data_type > data_container
Definition: tensor_container.hpp:121
Dtype data_type
Definition: tensor_container.hpp:49