Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
FindHao committed Oct 10, 2024
1 parent f0e04be commit ec68dea
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions torchbenchmark/util/experiment/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

import copy
import dataclasses
import os
import pathlib
import time
from typing import List, Optional, Tuple, Union

import psutil

import torch

from torchbenchmark import ModelTask
from torchbenchmark.util.experiment.instantiator import TorchBenchModelConfig
from torchbenchmark.util.model import BenchmarkModel
import psutil
import os

WARMUP_ROUNDS = 10
BENCHMARK_ITERS = 15
Expand All @@ -32,10 +34,12 @@ class TorchBenchModelMetrics:
pt2_graph_breaks: Optional[float]
model_flops: Optional[float]


def maybe_synchronize(device: str):
if device == "cuda":
torch.cuda.synchronize()


def get_latencies(
func, device: str, nwarmup=WARMUP_ROUNDS, num_iter=BENCHMARK_ITERS
) -> List[float]:
Expand Down Expand Up @@ -84,8 +88,12 @@ def get_peak_memory(
from torchbenchmark._components.model_analyzer.TorchBenchAnalyzer import (
ModelAnalyzer,
)

mem_model_analyzer = ModelAnalyzer(
export_metrics_file, new_metrics_needed, metrics_gpu_backend, cpu_monitored_pid
export_metrics_file,
new_metrics_needed,
metrics_gpu_backend,
cpu_monitored_pid,
)
else:
mem_model_analyzer = None
Expand Down

0 comments on commit ec68dea

Please sign in to comment.