forked from pytorch/FBGEMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-organize GenAI package init (copy of D64770837) (pytorch#3268)
Summary: Pull Request resolved: pytorch#3268 X-link: facebookresearch/FBGEMM#368 - Re-organize GenAI package init (copy of D64770837) Reviewed By: jwfromm Differential Revision: D64795669 fbshipit-source-id: 825e14e4dbc050403f47f4c6aa7b87664b35f38d
- Loading branch information
1 parent
c195f87
commit 97d32bc
Showing
9 changed files
with
113 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
from fbgemm_gpu.experimental.gen_ai.utils.loader import load_custom_library | ||
|
||
# Load all custom attention operators. | ||
load_custom_library( | ||
"//deeplearning/fbgemm/fbgemm_gpu/experimental/gen_ai:attention_ops" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
from fbgemm_gpu.experimental.gen_ai.utils.loader import load_custom_library | ||
|
||
# Load all custom gemm operators. | ||
load_custom_library("//deeplearning/fbgemm/fbgemm_gpu/experimental/gen_ai:gemm_ops") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
from fbgemm_gpu.experimental.gen_ai.utils.loader import load_custom_library | ||
|
||
# Load all custom kv cache operators. | ||
load_custom_library("//deeplearning/fbgemm/fbgemm_gpu/experimental/gen_ai:kv_cache_ops") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
import os | ||
|
||
import torch | ||
|
||
|
||
def load_custom_library(lib_name: str) -> None: | ||
""" | ||
Load a custom library implemented in C++. This | ||
helper function handles loading libraries both in | ||
fbcode and OSS. | ||
""" | ||
try: | ||
# pyre-ignore[21] | ||
# @manual=//deeplearning/fbgemm/fbgemm_gpu:test_utils | ||
from fbgemm_gpu import open_source | ||
|
||
# pyre-ignore[21] | ||
# @manual=//deeplearning/fbgemm/fbgemm_gpu:test_utils | ||
from fbgemm_gpu.docs.version import __version__ # noqa: F401 | ||
except Exception: | ||
open_source: bool = False | ||
|
||
# In open source, all custom ops are packaged into a single library | ||
# that we load. | ||
# pyre-ignore[16] | ||
if open_source: | ||
torch.ops.load_library( | ||
os.path.join( | ||
os.path.dirname(os.path.dirname(__file__)), | ||
"fbgemm_gpu_experimental_gen_ai_py.so", | ||
) | ||
) | ||
torch.classes.load_library( | ||
os.path.join( | ||
os.path.dirname(os.path.dirname(__file__)), | ||
"fbgemm_gpu_experimental_gen_ai_py.so", | ||
) | ||
) | ||
else: | ||
torch.ops.load_library(lib_name) |