mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/28731 as title Test Plan: ``` Before: buck run mode/opt caffe2/benchmarks/operator_benchmark:benchmark_all_test -- --operator sigmoid Invalidating internal cached state: Buck configuration options changed between invocations. This may cause slower builds. Changed value project.buck_out='buck-out/opt' (was 'buck-out/dev') ... and 69 more. See logs for all changes Parsing buck files: finished in 7.2 sec Creating action graph: finished in 10.0 sec Building: finished in 06:38.4 min (100%) 29890/29890 jobs, 29890 updated Total time: 06:55.7 min # ---------------------------------------- # PyTorch/Caffe2 Operator Micro-benchmarks # ---------------------------------------- # Tag : short # Benchmarking PyTorch: sigmoid With this diff buck run mode/opt caffe2/benchmarks/operator_benchmark:benchmark_all_test -- --operator sigmoid Parsing buck files: finished in 6.4 sec Creating action graph: finished in 9.8 sec Building: finished in 06:35.9 min (100%) 29892/29892 jobs, 29892 updated Total time: 06:52.1 min Reviewed By: hl475 Differential Revision: D18152071 fbshipit-source-id: 80c29570581bbd2f0e78e2df32734c17a2b036ee
53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
from __future__ import unicode_literals
|
|
|
|
import operator_benchmark as op_bench
|
|
import benchmark_caffe2 as op_bench_c2
|
|
from benchmark_caffe2 import Caffe2BenchmarkBase # noqa
|
|
from caffe2.python import core
|
|
|
|
|
|
"""Microbenchmarks for element-wise Add operator. Supports both Caffe2/PyTorch."""
|
|
|
|
# Configs for C2 add operator
|
|
add_long_configs = op_bench.cross_product_configs(
|
|
M=[8, 64, 128],
|
|
N=range(2, 10, 3),
|
|
K=[2 ** x for x in range(0, 3)],
|
|
dtype=["int", "float"],
|
|
tags=["long"]
|
|
)
|
|
|
|
|
|
add_short_configs = op_bench.config_list(
|
|
attrs=[
|
|
[8, 16, 32, "int"],
|
|
[16, 16, 64, "float"],
|
|
[64, 64, 128, "int"],
|
|
],
|
|
attr_names=["M", "N", "K", "dtype"],
|
|
tags=["short"],
|
|
)
|
|
|
|
class AddBenchmark(op_bench_c2.Caffe2BenchmarkBase):
|
|
def init(self, M, N, K, dtype):
|
|
self.input_one = self.tensor([M, N, K], dtype)
|
|
self.input_two = self.tensor([M, N, K], dtype)
|
|
self.output = self.tensor([M, N, K], dtype)
|
|
self.set_module_name("add")
|
|
|
|
def forward(self):
|
|
op = core.CreateOperator(
|
|
"Add", [self.input_one, self.input_two], self.output, **self.args
|
|
)
|
|
return op
|
|
|
|
|
|
op_bench_c2.generate_c2_test(add_long_configs + add_short_configs, AddBenchmark)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
op_bench.benchmark_runner.main()
|