Skip to content

Commit

Permalink
[Bazel] Build ATen_CPU_AVX2 lib with AVX2 arch flags enabled (pytor…
Browse files Browse the repository at this point in the history
…ch#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
  • Loading branch information
malfet authored and facebook-github-bot committed Apr 28, 2020
1 parent b37080d commit ebcacd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ intern_build_aten_ops(
copts = ATEN_COPTS,
deps = [
":aten_headers",
"@sleef",
"@fbgemm",
],
)
Expand Down
11 changes: 9 additions & 2 deletions aten.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

CPU_CAPABILITY_NAMES = ["DEFAULT", "AVX", "AVX2"]
CAPABILITY_COMPILER_FLAGS = {
"AVX2": ["-mavx2", "-mfma"],
"AVX": ["-mavx"],
"DEFAULT": [],
}

PREFIX = "aten/src/ATen/native/"

def intern_build_aten_ops(copts, deps):
Expand All @@ -27,11 +33,12 @@ def intern_build_aten_ops(copts, deps):
copts = copts + [
"-DCPU_CAPABILITY=" + cpu_capability,
"-DCPU_CAPABILITY_" + cpu_capability,
],
] + CAPABILITY_COMPILER_FLAGS[cpu_capability],
deps = deps,
linkstatic = 1,
)
cc_library(
name = "ATen_CPU",
srcs = ["ATen_CPU_" + cpu_capability for cpu_capability in CPU_CAPABILITY_NAMES],
deps = [":ATen_CPU_" + cpu_capability for cpu_capability in CPU_CAPABILITY_NAMES],
linkstatic = 1,
)
2 changes: 1 addition & 1 deletion third_party/sleef.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SLEEF_PUBLIC_INCLUDES = [
]

SLEEF_VISIBILITY = [
"@pytorch//:__subpackages__",
"//visibility:public",
]

cc_binary(
Expand Down

0 comments on commit ebcacd5

Please sign in to comment.