Skip to content

Commit ebcacd5

Browse files
malfetfacebook-github-bot
authored andcommittedApr 28, 2020
[Bazel] Build ATen_CPU_AVX2 lib with AVX2 arch flags enabled (pytorch#37381)
Summary: Make sleef dependency public so that `ATen_CPU_{capability}` libs can depend on it Pull Request resolved: pytorch#37381 Test Plan: CI Differential Revision: D21273443 Pulled By: malfet fbshipit-source-id: 7f756c7f3c605e51cf0c27ea37f687913cd48708
1 parent b37080d commit ebcacd5

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
 

‎BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ intern_build_aten_ops(
637637
copts = ATEN_COPTS,
638638
deps = [
639639
":aten_headers",
640+
"@sleef",
640641
"@fbgemm",
641642
],
642643
)

‎aten.bzl

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
load("@rules_cc//cc:defs.bzl", "cc_library")
22

33
CPU_CAPABILITY_NAMES = ["DEFAULT", "AVX", "AVX2"]
4+
CAPABILITY_COMPILER_FLAGS = {
5+
"AVX2": ["-mavx2", "-mfma"],
6+
"AVX": ["-mavx"],
7+
"DEFAULT": [],
8+
}
9+
410
PREFIX = "aten/src/ATen/native/"
511

612
def intern_build_aten_ops(copts, deps):
@@ -27,11 +33,12 @@ def intern_build_aten_ops(copts, deps):
2733
copts = copts + [
2834
"-DCPU_CAPABILITY=" + cpu_capability,
2935
"-DCPU_CAPABILITY_" + cpu_capability,
30-
],
36+
] + CAPABILITY_COMPILER_FLAGS[cpu_capability],
3137
deps = deps,
38+
linkstatic = 1,
3239
)
3340
cc_library(
3441
name = "ATen_CPU",
35-
srcs = ["ATen_CPU_" + cpu_capability for cpu_capability in CPU_CAPABILITY_NAMES],
42+
deps = [":ATen_CPU_" + cpu_capability for cpu_capability in CPU_CAPABILITY_NAMES],
3643
linkstatic = 1,
3744
)

‎third_party/sleef.BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SLEEF_PUBLIC_INCLUDES = [
5151
]
5252

5353
SLEEF_VISIBILITY = [
54-
"@pytorch//:__subpackages__",
54+
"//visibility:public",
5555
]
5656

5757
cc_binary(

0 commit comments

Comments
 (0)
Please sign in to comment.