This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conditional import in accelerator_lowering.py to avoid ImportError (
#1633) Summary: Pull Request resolved: #1633 Alternative approach to #1631. Handling ImportError of accelerator in accelerator_lowering.py instead of new_task.py. accelerator function is both used as a declarator on class AcceleratorTransformerLayers and called directly in lower_modules_to_accelerator. In addition to adding the try block for importing accelerator, accelerator_lowering_supported is used in lower_modules_to_accelerator to avoid ImportError. Reviewed By: mikekgfb Differential Revision: D26885302 fbshipit-source-id: 0630494f5d44fff9869e8d88e3bb23224fe4826f
- Loading branch information
1 parent
8331191
commit 653a05e
Showing
3 changed files
with
50 additions
and
2 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,33 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reservedimport functools | ||
|
||
import functools | ||
|
||
# module decorator for specifying acceleration | ||
# The purpose is to avoid ImportError when glow_decorator is not available | ||
class accelerator: | ||
def __init__(self, specs, inputs_function=None): | ||
pass | ||
|
||
def __call__(self, module): | ||
@functools.wraps(module) | ||
def wrapper(*args, **kwargs): | ||
return module(*args, **kwargs) | ||
|
||
return wrapper | ||
|
||
@classmethod | ||
def _dfs_modules(cls, node, backend, results, submod_path=""): | ||
pass | ||
|
||
@classmethod | ||
def get_modules(cls, model, backend): | ||
pass | ||
|
||
@classmethod | ||
def get_module_from_path(cls, model, prefixes): | ||
pass | ||
|
||
@classmethod | ||
def get_embedding_module_from_path(cls, model, submod_path): | ||
pass |