Skip to content

Commit

Permalink
Add 1d indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
gojakuch committed Sep 2, 2024
1 parent 7fd00e6 commit 51ddadc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions include/clad/Differentiator/KokkosBuiltins.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ constructor_reverse_forw(
::Kokkos::View<DataType, ViewParams...>(
"_diff_" + name, idx0, idx1, idx2, idx3, idx4, idx5, idx6, idx7)};
}
template <class DataType, class... ViewParams>
void constructor_pullback(::Kokkos::View<DataType, ViewParams...>* v,
const ::std::string& name, const size_t& idx0,
const size_t& idx1, const size_t& idx2,
const size_t& idx3, const size_t& idx4,
const size_t& idx5, const size_t& idx6,
const size_t& idx7,
::Kokkos::View<DataType, ViewParams...>* d_v,
const ::std::string* /*d_name*/,
const size_t& /*d_idx0*/, const size_t* /*d_idx1*/,
const size_t* /*d_idx2*/, const size_t* /*d_idx3*/,
const size_t* /*d_idx4*/, const size_t* /*d_idx5*/,
const size_t* /*d_idx6*/, const size_t* /*d_idx7*/) {}

/// View indexing
template <typename View, typename Idx>
Expand Down Expand Up @@ -125,6 +138,19 @@ operator_call_pushforward(const View* v, Idx0 i0, Idx1 i1, Idx2 i2, Idx3 i3,
return {(*v)(i0, i1, i2, i3, i4, i5, i6, i7),
(*d_v)(i0, i1, i2, i3, i4, i5, i6, i7)};
}
template <class DataType, class... ViewParams, typename Idx>
clad::ValueAndAdjoint<double&, double&> operator_call_reverse_forw(
const ::Kokkos::View<DataType, ViewParams...>* v, Idx i0,
const ::Kokkos::View<DataType, ViewParams...>* d_v, Idx /*d_i0*/) {
return {(*v)(i0), (*d_v)(i0)};
}
template <class DataType, class... ViewParams, typename Diff, typename Idx>
void operator_call_pullback(const ::Kokkos::View<DataType, ViewParams...>* v,
Idx i0, Diff d_y,
::Kokkos::View<DataType, ViewParams...>* d_v,
Idx* /*d_i0*/) {
(*d_v)(i0) += d_y;
}
} // namespace class_functions

/// Kokkos functions (view utils)
Expand Down

0 comments on commit 51ddadc

Please sign in to comment.