Skip to content

Commit

Permalink
Exclude nanobind adapter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fthaler committed Oct 29, 2024
1 parent cc97916 commit 5732d10
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions include/gridtools/storage/adapter/nanobind_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "../../common/array.hpp"
#include "../../common/integral_constant.hpp"
#include "../../common/tuple.hpp"
#include "../../sid/as_const.hpp"
#include "../../sid/simple_ptr_holder.hpp"
#include "../../sid/synthetic.hpp"
#include "../../sid/unknown_kind.hpp"
Expand Down Expand Up @@ -79,27 +78,24 @@ namespace gridtools {
class Strides = fully_dynamic_strides<sizeof...(Sizes)>,
class StridesKind = sid::unknown_kind>
auto as_sid(nanobind::ndarray<T, nanobind::shape<Sizes...>, Args...> ndarray,
Strides stride_spec = {},
Strides stride_spec_ = {},
StridesKind = {}) {
using sid::property;
const auto ptr = ndarray.data();
constexpr auto ndim = sizeof...(Sizes);
assert(ndim == ndarray.ndim());
gridtools::array<std::size_t, ndim> shape;
std::copy_n(ndarray.shape_ptr(), ndim, shape.begin());
gridtools::array<std::size_t, ndim> strides;
std::copy_n(ndarray.stride_ptr(), ndim, strides.begin());
const auto static_strides = select_static_strides(stride_spec, strides.data());

return sid::add_const(
std::integral_constant<bool, ndarray.ReadOnly>{},
sid::synthetic()
.template set<property::origin>(sid::host_device::simple_ptr_holder<T *>{ptr})
.template set<property::strides>(static_strides)
.template set<property::strides_kind, StridesKind>()
.template set<property::lower_bounds>(gridtools::array<integral_constant<std::size_t, 0>, ndim>())
.template set<property::upper_bounds>(shape)
);
gridtools::array<std::size_t, ndim> strides_;
std::copy_n(ndarray.stride_ptr(), ndim, strides_.begin());
const auto strides = select_static_strides(stride_spec_, strides_.data());

return sid::synthetic()
.template set<property::origin>(sid::host_device::simple_ptr_holder<T *>{ptr})
.template set<property::strides>(strides)
.template set<property::strides_kind, StridesKind>()
.template set<property::lower_bounds>(gridtools::array<integral_constant<std::size_t, 0>, ndim>())
.template set<property::upper_bounds>(shape);
}
} // namespace nanobind_sid_adapter_impl_

Expand Down

0 comments on commit 5732d10

Please sign in to comment.