@@ -140,7 +140,6 @@ namespace xt
140140
141141 void init_tensor (const shape_type& shape, const strides_type& strides);
142142 void init_from_python ();
143- void compute_backstrides ();
144143
145144 inner_shape_type& shape_impl () noexcept ;
146145 const inner_shape_type& shape_impl () const noexcept ;
@@ -281,7 +280,7 @@ namespace xt
281280 this ->m_ptr = tmp.release ().ptr ();
282281 m_shape = shape;
283282 m_strides = strides;
284- compute_backstrides ( );
283+ adapt_strides (m_shape, m_strides, m_backstrides );
285284 m_data = container_type (reinterpret_cast <pointer>(PyArray_DATA (this ->python_array ())),
286285 static_cast <size_type>(PyArray_SIZE (this ->python_array ())));
287286 }
@@ -297,20 +296,11 @@ namespace xt
297296 std::copy (PyArray_DIMS (this ->python_array ()), PyArray_DIMS (this ->python_array ()) + N, m_shape.begin ());
298297 std::transform (PyArray_STRIDES (this ->python_array ()), PyArray_STRIDES (this ->python_array ()) + N, m_strides.begin (),
299298 [](auto v) { return v / sizeof (T); });
300- compute_backstrides ( );
299+ adapt_strides (m_shape, m_strides, m_backstrides );
301300 m_data = container_type (reinterpret_cast <pointer>(PyArray_DATA (this ->python_array ())),
302301 static_cast <size_type>(PyArray_SIZE (this ->python_array ())));
303302 }
304303
305- template <class T , std::size_t N>
306- inline void pytensor<T, N>::compute_backstrides()
307- {
308- for (size_type i = 0 ; i < m_shape.size (); ++i)
309- {
310- m_backstrides[i] = m_strides[i] * (m_shape[i] - 1 );
311- }
312- }
313-
314304 template <class T , std::size_t N>
315305 inline auto pytensor<T, N>::shape_impl() noexcept -> inner_shape_type&
316306 {
0 commit comments