Skip to content

Commit

Permalink
Fix invocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
datumbox committed Sep 6, 2021
1 parent f486437 commit 526faab
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/cpp/hello_world/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ int main()
std::cout << "Other error: " << e.what() << "\n";
return -1;
}
model->eval();

// Create a random input tensor and run it through the model.
auto in = torch::rand({1, 3, 10, 10});
auto out = model->forward(in);
auto out = model.forward(in);

std::cout << out.sizes();

if (torch::cuda::is_available()) {
// Move model and inputs to GPU
model->to(torch::kCUDA);
model.to(torch::kCUDA);
auto gpu_in = in.to(torch::kCUDA);
auto gpu_out = model->forward(gpu_in);
auto gpu_out = model.forward(gpu_in);

std::cout << gpu_out.sizes();
}
Expand Down

0 comments on commit 526faab

Please sign in to comment.