Skip to content

Commit

Permalink
[BUGFIX] Fix Windows GPU VS2019 build (apache#20206)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Shen committed Apr 24, 2021
1 parent e8ad36a commit 9a05b6e
Showing 1 changed file with 61 additions and 6 deletions.
67 changes: 61 additions & 6 deletions src/ndarray/ndarray_function-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,62 @@ void EvalRandom<DEVICE, GaussianDistribution>(
}
}

#if defined(__CUDACC__)

template<>
void EvalRandom<gpu, GammaDistribution>(
const real_t &alpha,
const real_t &beta,
const Resource &resource,
TBlob *ret,
RunContext ctx) {
EvalRandom<cpu, GammaDistribution>(alpha, beta, resource, ret, ctx);
}

template<>
void EvalRandom<gpu, ExponentialDistribution>(
const real_t &lambda,
const real_t &dummy, // this is to satisfy the SampleOp lambda signature
const Resource &resource,
TBlob *ret,
RunContext ctx) {
EvalRandom<cpu, ExponentialDistribution>(lambda, dummy, resource, ret, ctx);
}

template<>
void EvalRandom<gpu, PoissonDistribution>(
const real_t &lambda,
const real_t &dummy, // this is to satisfy the SampleOp lambda signature
const Resource &resource,
TBlob *ret,
RunContext ctx) {
EvalRandom<cpu, PoissonDistribution>(lambda, dummy, resource, ret, ctx);
}

template<>
void EvalRandom<gpu, NegBinomialDistribution>(
const real_t &k,
const real_t &p,
const Resource &resource,
TBlob *ret,
RunContext ctx) {
EvalRandom<cpu, NegBinomialDistribution>(k, p, resource, ret, ctx);
}

template<>
void EvalRandom<DEVICE, GammaDistribution>(
void EvalRandom<gpu, GenNegBinomialDistribution>(
const real_t &mu,
const real_t &alpha,
const Resource &resource,
TBlob *ret,
RunContext ctx) {
EvalRandom<cpu, GenNegBinomialDistribution>(mu, alpha, resource, ret, ctx);
}

#else

template<>
void EvalRandom<cpu, GammaDistribution>(
const real_t &alpha,
const real_t &beta,
const Resource &resource,
Expand Down Expand Up @@ -259,9 +313,8 @@ void EvalRandom<DEVICE, GammaDistribution>(
}
}


template<>
void EvalRandom<DEVICE, ExponentialDistribution>(
void EvalRandom<cpu, ExponentialDistribution>(
const real_t &lambda,
const real_t &dummy, // this is to satisfy the SampleOp lambda signature
const Resource &resource,
Expand Down Expand Up @@ -290,7 +343,7 @@ void EvalRandom<DEVICE, ExponentialDistribution>(
}

template<>
void EvalRandom<DEVICE, PoissonDistribution>(
void EvalRandom<cpu, PoissonDistribution>(
const real_t &lambda,
const real_t &dummy, // this is to satisfy the SampleOp lambda signature
const Resource &resource,
Expand Down Expand Up @@ -319,7 +372,7 @@ void EvalRandom<DEVICE, PoissonDistribution>(
}

template<>
void EvalRandom<DEVICE, NegBinomialDistribution>(
void EvalRandom<cpu, NegBinomialDistribution>(
const real_t &k,
const real_t &p,
const Resource &resource,
Expand Down Expand Up @@ -348,7 +401,7 @@ void EvalRandom<DEVICE, NegBinomialDistribution>(
}

template<>
void EvalRandom<DEVICE, GenNegBinomialDistribution>(
void EvalRandom<cpu, GenNegBinomialDistribution>(
const real_t &mu,
const real_t &alpha,
const Resource &resource,
Expand Down Expand Up @@ -376,6 +429,8 @@ void EvalRandom<DEVICE, GenNegBinomialDistribution>(
}
}

#endif // #ifndef __CUDACC__

template<>
void Eval<DEVICE>(const real_t &rhs, TBlob *ret, RunContext ctx) {
mshadow::Stream<DEVICE> *s = ctx.get_stream<DEVICE>();
Expand Down

0 comments on commit 9a05b6e

Please sign in to comment.