mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: Context: https://github.com/pytorch/pytorch/pull/53299#discussion_r587882857 These are the only hand-written parts of this diff: - the addition to `.github/workflows/lint.yml` - the file endings changed in these four files (to appease FB-internal land-blocking lints): - `GLOSSARY.md` - `aten/src/ATen/core/op_registration/README.md` - `scripts/README.md` - `torch/csrc/jit/codegen/fuser/README.md` The rest was generated by running this command (on macOS): ``` git grep -I -l ' $' -- . ':(exclude)**/contrib/**' ':(exclude)third_party' | xargs gsed -i 's/ *$//' ``` I looked over the auto-generated changes and didn't see anything that looked problematic. Pull Request resolved: https://github.com/pytorch/pytorch/pull/53406 Test Plan: This run (after adding the lint but before removing existing trailing spaces) failed: - https://github.com/pytorch/pytorch/runs/2043032377 This run (on the tip of this PR) succeeded: - https://github.com/pytorch/pytorch/runs/2043296348 Reviewed By: walterddr, seemethere Differential Revision: D26856620 Pulled By: samestep fbshipit-source-id: 3f0de7f7c2e4b0f1c089eac9b5085a58dd7e0d97
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
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()
|