Skip to content

Commit 52557ac

Browse files
Jason Chenmeta-codesync[bot]
authored andcommitted
Decouple ATEN from Feature Gates Deps (#4965)
Summary: Pull Request resolved: #4965 X-link: https://github.com/facebookresearch/FBGEMM/pull/1983 Reviewed By: q10 Differential Revision: D83725615 fbshipit-source-id: 2a548e77425b1c9f2a66e0cd6d5abbaa9b37a312
1 parent 2d7847a commit 52557ac

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-17
lines changed

fbgemm_gpu/cmake/TbeTraining.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ gpu_cpp_library(
7575
${fbgemm_sources_include_directories}
7676
CPU_SRCS
7777
src/config/feature_gates.cpp
78+
src/config/feature_gates_torch_op.cpp
7879
DESTINATION
7980
fbgemm_gpu)
8081

fbgemm_gpu/fbgemm_gpu/config/feature_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import torch
1212

1313
try:
14-
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:config_cpp")
14+
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:config_cpp_torch_op")
1515
except Exception:
1616
import fbgemm_gpu # noqa F401
1717

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
#pragma once
10+
11+
/*
12+
* We annotate the public FBGEMM functions and hide the rest. Those
13+
* public symbols can be called via fbgemm_gpu::func() or pytorch
14+
* operator dispatcher. We'll hide other symbols, especially CUB APIs,
15+
* because different .so may include the same CUB CUDA kernels, which
16+
* results in confusion and libA may end up calling libB's CUB kernel,
17+
* causing failures when we static link libcudart_static.a
18+
*/
19+
#define DLL_PUBLIC __attribute__((visibility("default")))

fbgemm_gpu/include/fbgemm_gpu/utils/ops_utils.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ __builtin_ia32_serialize(void) {
2929
#include <ATen/core/op_registration/op_registration.h>
3030
#include <torch/library.h>
3131

32-
/*
33-
* We annotate the public FBGEMM functions and hide the rest. Those
34-
* public symbols can be called via fbgemm_gpu::func() or pytorch
35-
* operator dispatcher. We'll hide other symbols, especially CUB APIs,
36-
* because different .so may include the same CUB CUDA kernels, which
37-
* results in confusion and libA may end up calling libB's CUB kernel,
38-
* causing failures when we static link libcudart_static.a
39-
*/
40-
#define DLL_PUBLIC __attribute__((visibility("default")))
32+
// NOLINTNEXTLINE(misc-unused-using-decls)
33+
#include "fbgemm_gpu/utils/function_types.h"
4134

4235
////////////////////////////////////////////////////////////////////////////////
4336
/// Op Dispatch Macros

fbgemm_gpu/src/config/feature_gates.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
*/
88

99
#include "fbgemm_gpu/config/feature_gates.h"
10-
#include "fbgemm_gpu/utils/ops_utils.h"
10+
#include "fbgemm_gpu/utils/function_types.h"
1111

1212
#ifdef FBGEMM_FBCODE
1313
#include "fbgemm_gpu/config/feature_gates_fb.h"
1414
#endif
1515

1616
#include <cstdlib>
1717
#include <map>
18+
#include <stdexcept>
1819
#include <string>
1920

2021
namespace fbgemm_gpu::config {
@@ -80,9 +81,3 @@ DLL_PUBLIC bool is_feature_enabled(const FbFeatureGateName& feature) {
8081
#endif
8182

8283
} // namespace fbgemm_gpu::config
83-
84-
TORCH_LIBRARY_FRAGMENT(fbgemm, m) {
85-
m.def(
86-
"check_feature_gate_key(str key) -> bool",
87-
fbgemm_gpu::config::check_feature_gate_key);
88-
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
#include <torch/library.h>
10+
#include "fbgemm_gpu/config/feature_gates.h"
11+
12+
TORCH_LIBRARY_FRAGMENT(fbgemm, m) {
13+
m.def(
14+
"check_feature_gate_key(str key) -> bool",
15+
fbgemm_gpu::config::check_feature_gate_key);
16+
}

0 commit comments

Comments
 (0)