Lines Matching defs:shape

34    and dimension types (e.g. shape, strides, indexing), instead of inflicting this
283 static void append_extents(list& /* shape */) { }
295 // appends the extents to shape
296 static void append_extents(list& shape) {
297 shape.append(N);
298 array_info<T>::append_extents(shape);
342 // Storing the shape & strides in local variables (i.e. these arrays) allows the compiler to
351 unchecked_reference(const void *data, const ssize_t *shape, const ssize_t *strides, enable_if_t<!Dyn, ssize_t>)
354 shape_[i] = shape[i];
360 unchecked_reference(const void *data, const ssize_t *shape, const ssize_t *strides, enable_if_t<Dyn, ssize_t> dims)
361 : data_{reinterpret_cast<const unsigned char *>(data)}, shape_{shape}, strides_{strides}, dims_{dims} {}
387 /// Returns the shape (i.e. size) of dimension `dim`
388 ssize_t shape(ssize_t dim) const { return shape_[(size_t) dim]; }
553 // Constructs an array taking shape/strides from arbitrary container types
554 array(const pybind11::dtype &dt, ShapeContainer shape, StridesContainer strides,
558 *strides = c_strides(*shape, dt.itemsize());
560 auto ndim = shape->size();
562 pybind11_fail("NumPy: shape ndim doesn't match strides ndim");
577 api.PyArray_Type_, descr.release().ptr(), (int) ndim, shape->data(), strides->data(),
591 array(const pybind11::dtype &dt, ShapeContainer shape, const void *ptr = nullptr, handle base = handle())
592 : array(dt, std::move(shape), {}, ptr, base) { }
599 array(ShapeContainer shape, StridesContainer strides, const T *ptr, handle base = handle())
600 : array(pybind11::dtype::of<T>(), std::move(shape), std::move(strides), ptr, base) { }
603 array(ShapeContainer shape, const T *ptr, handle base = handle())
604 : array(std::move(shape), {}, ptr, base) { }
610 : array(pybind11::dtype(info), info.shape, info.strides, info.ptr) { }
619 return std::accumulate(shape(), shape() + ndim(), (ssize_t) 1, std::multiplies<ssize_t>());
643 const ssize_t* shape() const {
648 ssize_t shape(ssize_t dim) const {
651 return shape()[dim];
721 return detail::unchecked_mutable_reference<T, Dims>(mutable_data(), shape(), strides(), ndim());
735 return detail::unchecked_reference<T, Dims>(data(), shape(), strides(), ndim());
744 /// Resize array to given shape
787 static std::vector<ssize_t> c_strides(const std::vector<ssize_t> &shape, ssize_t itemsize) {
788 auto ndim = shape.size();
792 strides[i - 1] = strides[i] * shape[i];
797 static std::vector<ssize_t> f_strides(const std::vector<ssize_t> &shape, ssize_t itemsize) {
798 auto ndim = shape.size();
801 strides[i] = strides[i - 1] * shape[i - 1];
806 check_dimensions_impl(ssize_t(0), shape(), ssize_t(index)...);
811 template<typename... Ix> void check_dimensions_impl(ssize_t axis, const ssize_t* shape, ssize_t i, Ix... index) const {
812 if (i >= *shape) {
815 " with size " + std::to_string(*shape));
817 check_dimensions_impl(axis + 1, shape + 1, index...);
835 array_t(private_ctor, ShapeContainer &&shape, StridesContainer &&strides, const T *ptr, handle base)
836 : array(std::move(shape), std::move(strides), ptr, base) {}
858 array_t(ShapeContainer shape, StridesContainer strides, const T *ptr = nullptr, handle base = handle())
859 : array(std::move(shape), std::move(strides), ptr, base) { }
861 explicit array_t(ShapeContainer shape, const T *ptr = nullptr, handle base = handle())
862 : array_t(private_ctor{}, std::move(shape),
863 ExtraFlags & f_style ? f_strides(*shape, itemsize()) : c_strides(*shape, itemsize()),
1067 list shape;
1068 array_info<T>::append_extents(shape);
1069 return pybind11::dtype::from_args(pybind11::make_tuple(base_descr::dtype(), shape));
1288 common_iterator(void* ptr, const container_type& strides, const container_type& shape)
1293 value_type s = static_cast<value_type>(shape[i]);
1316 const container_type &shape)
1317 : m_shape(shape.size()), m_index(shape.size(), 0),
1321 for (size_t i = 0; i < shape.size(); ++i)
1322 m_shape[i] = shape[i];
1324 container_type strides(shape.size());
1326 init_common_iterator(buffers[i], shape, m_common_iterator[i], strides);
1351 const container_type &shape,
1354 auto buffer_shape_iter = buffer.shape.rbegin();
1356 auto shape_iter = shape.rbegin();
1359 while (buffer_shape_iter != buffer.shape.rend()) {
1372 iterator = common_iter(buffer.ptr, strides, shape);
1387 // Populates the shape and number of dimensions for the set of buffers. Returns a broadcast_trivial
1392 broadcast_trivial broadcast(const std::array<buffer_info, N> &buffers, ssize_t &ndim, std::vector<ssize_t> &shape) {
1397 shape.clear();
1398 shape.resize((size_t) ndim, 1);
1403 auto res_iter = shape.rbegin();
1404 auto end = buffers[i].shape.rend();
1405 for (auto shape_iter = buffers[i].shape.rbegin(); shape_iter != end; ++shape_iter, ++res_iter) {
1428 if (!std::equal(buffers[i].shape.cbegin(), buffers[i].shape.cend(), shape.cbegin()))
1434 auto end = buffers[i].shape.crend();
1435 for (auto shape_iter = buffers[i].shape.crbegin(), stride_iter = buffers[i].strides.crbegin();
1447 auto end = buffers[i].shape.cend();
1448 for (auto shape_iter = buffers[i].shape.cbegin(), stride_iter = buffers[i].strides.cbegin();
1527 std::vector<ssize_t> shape(0);
1528 auto trivial = broadcast(buffers, nd, shape);
1531 size_t size = std::accumulate(shape.begin(), shape.end(), (size_t) 1, std::multiplies<size_t>());
1541 if (trivial == broadcast_trivial::f_trivial) result = array_t<Return, array::f_style>(shape);
1542 else result = array_t<Return>(shape);
1585 multi_array_iterator<NVectorized> input_iter(buffers, output.shape);