Code: Select all
for i in range(263):
states = torch.rand(128, 4, 20, 20, device = device)
# time.sleep(1)
start_time = time.time()
policy, value, action_value = model(states)
end_time = time.time()
total_time = end_time - start_time
print(f"time cost:{total_time:.4f} second")
Code: Select all
time cost:0.0003 second
time cost:0.0003 second
time cost:0.0003 second
...
Code: Select all
time cost:0.0008 second
time cost:0.0009 second
time cost:0.0009 second
Code: Select all
std::shared_ptr results_tensor = std::make_shared();
std::shared_ptr model;
while(true)
{
auto start = std::chrono::high_resolution_clock::now();
*results_tensor = nn.model->forward({input});
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration duration = end - start;
{
std::lock_guard lock(cout_mutex);
std::cout