Skip to content

Commit

Permalink
Force a sync on non-CPU tensors for the benchmark to reflect the timi…
Browse files Browse the repository at this point in the history
…ng accurately.

ghstack-source-id: 758cd360497878e8d4415b208b28dd966bf141f5
Pull Request resolved: #47714
  • Loading branch information
Ashkan Aliabadi committed Dec 2, 2020
1 parent fa4527a commit 58e4319
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions binaries/speed_benchmark_torch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ int main(int argc, char** argv) {
FLAGS_warmup,
".");
for (int i = 0; i < FLAGS_warmup; ++i) {
module.forward(inputs);
module.forward(inputs).toTensor().cpu();
}

std::cout << "Main runs." << std::endl;
Expand All @@ -231,7 +231,7 @@ int main(int argc, char** argv) {
auto micros = timer.MicroSeconds();
for (int i = 0; i < FLAGS_iter; ++i) {
auto start = high_resolution_clock::now();
module.forward(inputs);
module.forward(inputs).toTensor().cpu();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
times.push_back(duration.count());
Expand Down

0 comments on commit 58e4319

Please sign in to comment.