diff --git a/include/cenet/math/tensor_shape.hpp b/include/cenet/math/tensor_shape.hpp index 42b0a30..8c45e76 100644 --- a/include/cenet/math/tensor_shape.hpp +++ b/include/cenet/math/tensor_shape.hpp @@ -41,6 +41,12 @@ struct static_shape : shape { return get_impl::value; } + template + static constexpr auto sget() { + return get_impl::value; + } + + static constexpr auto rank = sizeof...(Dims); static constexpr auto score = sizeof...(Dims); private: template @@ -63,6 +69,12 @@ template struct dynamic_shape : shape { dynamic_shape() = default; + template && ...)>> + explicit dynamic_shape(RDims... rtDimensions) { + store_impl<0>(rtDimensions...); + } + template = sizeof...(Dims))>> explicit dynamic_shape(const dynamic_shape& oth) { constexpr std::size_t ext_offset = ExtRank - sizeof...(Dims); @@ -86,6 +98,11 @@ struct dynamic_shape : shape { return get_impl::value == dynamic_extent ? dimensions[I] : get_impl::value; } + template + static constexpr auto sget() { + return get_impl::value; + } + std::size_t dimensions[sizeof...(Dims)]{}; private: template @@ -115,7 +132,14 @@ private: template struct score_impl : score_impl {}; + + template > + void store_impl(RDim first, RDims... rest) { + dimensions[I] = first; + store_impl(rest...); + } public: + static constexpr auto rank = sizeof...(Dims); static constexpr auto score = score_impl<0, Dims...>::value; };