mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-11 14:26:37 +03:00
Fix block dim and block number in droput
This commit is contained in:
parent
d1e90650dc
commit
1227d0bb31
@ -42,8 +42,10 @@ class DropoutGenerator {
|
||||
|
||||
void Generate(float* data, int n, float p) {
|
||||
CURAND_CALL(curandGenerateUniform(generator_, data, n));
|
||||
/* CUDA_CALL( gScalled<<<512, 512>>>(data, n, p) ); */
|
||||
gScalled<<<512, 512>>>(data, n, p);
|
||||
int numThreads = std::min(n, 512);
|
||||
int numBlocks = n / numThreads + (n % numThreads != 0);
|
||||
|
||||
gScalled<<<numBlocks, numThreads>>>(data, n, p);
|
||||
}
|
||||
|
||||
~DropoutGenerator() {
|
||||
|
@ -27,7 +27,7 @@ int main() {
|
||||
int layers = 64;
|
||||
|
||||
std::cerr << "Number of elements in tensor: " << rows * cols * layers << std::endl;
|
||||
int rep = 10;
|
||||
int rep = 1000;
|
||||
const float prob = 0.5f;
|
||||
|
||||
Tensor dropoutMatrix;
|
||||
@ -40,16 +40,6 @@ int main() {
|
||||
|
||||
for (int i = 0; i < rep;++i) {
|
||||
dropout.Generate(dropoutMatrix, prob);
|
||||
cudaDeviceSynchronize();
|
||||
std::vector<float> tmpVector(rows * cols * layers);
|
||||
dropoutMatrix >> tmpVector;
|
||||
std::cerr << dropoutMatrix->debug();
|
||||
|
||||
/* for (size_t i = 0; i < 30; ++i) std::cerr << tmpVector[i] << " "; */
|
||||
/* std::cerr <<"| non-zero: "; */
|
||||
/* int counter = 0; */
|
||||
/* for (auto& v : tmpVector) counter += (v != 0.0f); */
|
||||
/* std::cerr << counter << std::endl; */
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user