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 23, 2021
1 parent 2d9c3b5 commit d2b40a5
Showing 1 changed file with 61 additions and 5 deletions.
66 changes: 61 additions & 5 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<DEVICE, GammaDistribution>(
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<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 @@ -261,7 +315,7 @@ 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 +344,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 +373,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 +402,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 +430,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 d2b40a5

Please sign in to comment.