Skip to content

Commit

Permalink
Fix op benchmarks error in OSS environment (pytorch#19518)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#19518

Previous design needs to run the op benchmarks from PyTorch root directory which could lead to `module not found` error in OSS environment. This diff fixes that issue by making the benchmark to be launched in the `benchmarks` folder.

Reviewed By: ilia-cher

Differential Revision: D15020787

fbshipit-source-id: eb09814a33432a66cc857702bc86538cd17bea3b
  • Loading branch information
mingzhe09088 authored and facebook-github-bot committed Apr 19, 2019
1 parent 5da7b74 commit 26f12af
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 13 deletions.
7 changes: 7 additions & 0 deletions benchmarks/operator_benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PyTorch/Caffe2 Operator Micro-benchmarks

## Run benchmarks
Go to `pytorch-src-folder/benchmarks`
`python -m operator_benchmark.ops.matmul_test`

should report the execution time of matmul operator with PyTorch and Caffe2
2 changes: 1 addition & 1 deletion benchmarks/operator_benchmark/benchmark_caffe2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from __future__ import unicode_literals

from caffe2.python import core, workspace
from benchmarks.operator_benchmark import benchmark_core, benchmark_utils
from operator_benchmark import benchmark_core, benchmark_utils

"""Caffe2 performance microbenchmarks.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/operator_benchmark/benchmark_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import timeit
import json

from benchmarks.operator_benchmark import benchmark_utils
from operator_benchmark import benchmark_utils

"""Performance microbenchmarks.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/operator_benchmark/benchmark_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import print_function
from __future__ import unicode_literals

from benchmarks.operator_benchmark import benchmark_core, benchmark_utils
from operator_benchmark import benchmark_core, benchmark_utils

import torch

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/operator_benchmark/benchmark_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from caffe2.python import workspace

from benchmarks.operator_benchmark import benchmark_core
from operator_benchmark import benchmark_core

"""Performance microbenchmarks's main binary.
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/operator_benchmark/benchmark_test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from __future__ import unicode_literals


from benchmarks.operator_benchmark.benchmark_caffe2 import Caffe2OperatorTestCase
from benchmarks.operator_benchmark.benchmark_pytorch import PyTorchOperatorTestCase
from benchmarks.operator_benchmark.benchmark_utils import * # noqa
from operator_benchmark.benchmark_caffe2 import Caffe2OperatorTestCase
from operator_benchmark.benchmark_pytorch import PyTorchOperatorTestCase
from operator_benchmark.benchmark_utils import * # noqa


def generate_test(configs, map_config, ops, OperatorTestCase):
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/operator_benchmark/ops/add_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import print_function
from __future__ import unicode_literals

from benchmarks.operator_benchmark import benchmark_core, benchmark_runner
from benchmarks.operator_benchmark.benchmark_test_generator import *
from operator_benchmark import benchmark_core, benchmark_runner
from operator_benchmark.benchmark_test_generator import *

import torch

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/operator_benchmark/ops/benchmark_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import print_function
from __future__ import unicode_literals

from benchmarks.operator_benchmark import benchmark_runner
from benchmarks.operator_benchmark.ops import ( # noqa
from operator_benchmark import benchmark_runner
from operator_benchmark.ops import ( # noqa
add_test, # noqa
matmul_test) # noqa

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/operator_benchmark/ops/matmul_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import print_function
from __future__ import unicode_literals

from benchmarks.operator_benchmark import benchmark_core, benchmark_runner
from benchmarks.operator_benchmark.benchmark_test_generator import *
from operator_benchmark import benchmark_core, benchmark_runner
from operator_benchmark.benchmark_test_generator import *

import torch

Expand Down

0 comments on commit 26f12af

Please sign in to comment.