You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am reducing a boolean matrix to an integer vector (cf code sample in the section below).
I only need coalescedReduction, but the reduce function instantiates stridedReduction too and this is where the problem happens, at line 150 of strided_reduction.cuh: the if statement is not determined at compile time (it's not a C++17 if constexpr) so it attempts to compile stridedSummationKernel even if the input and output types are different, in which case it can't compile.
Note that at the moment I solved the problem for my use case by calling directly coalescedReduction instead of reduce.
Steps/Code to reproduce bug
This is approximately what my code looks like:
bool* in;
int* out;
raft::linalg::reduce(
out, in, N, N, 0, true, true, stream, false,
[] __device__(bool value, int idx) {
returnstatic_cast<int>(value);
},
raft::Sum<int>(), raft::Nop<int>());
Compilation error:
include/raft/linalg/strided_reduction.cuh(152): error: no instance of function template "raft::linalg::stridedSummationKernel" matches the argument list
argument types are: (int *, const __nv_bool *, int, int, int, lambda [](__nv_bool, int)->int)
detected during: instantiation of "void raft::linalg::stridedReduction(OutType *, const InType *, IdxType, IdxType, OutType, cudaStream_t, __nv_bool, MainLambda, ReduceLambda, FinalLambda) [with InType=__nv_bool, OutType=int, IdxType=int, MainLambda=lambda [](__nv_bool, int)->int, ReduceLambda=raft::Sum<int>, FinalLambda=raft::Nop<int, int>]"
Expected behavior
The reduction should support different input and output types as suggested by the template parameters and the docs.
The text was updated successfully, but these errors were encountered:
This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.
)
Closes#165
Uses a C++17 `if constexpr` to discard at compile time a code path that doesn't support different input and output types, and adds a test for such a case (the test won't compile without that `constexpr` keyword).
Authors:
- Louis Sugy (https://github.com/Nyrio)
Approvers:
- Corey J. Nolet (https://github.com/cjnolet)
- Brad Rees (https://github.com/BradReesWork)
URL: #296
Describe the bug
I am reducing a boolean matrix to an integer vector (cf code sample in the section below).
I only need
coalescedReduction
, but thereduce
function instantiatesstridedReduction
too and this is where the problem happens, at line 150 of strided_reduction.cuh: theif
statement is not determined at compile time (it's not a C++17if constexpr
) so it attempts to compilestridedSummationKernel
even if the input and output types are different, in which case it can't compile.Note that at the moment I solved the problem for my use case by calling directly
coalescedReduction
instead ofreduce
.Steps/Code to reproduce bug
This is approximately what my code looks like:
Compilation error:
Expected behavior
The reduction should support different input and output types as suggested by the template parameters and the docs.
The text was updated successfully, but these errors were encountered: