-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Whisper from Huggingface. (#1769)
Summary: Instead of making changes, using HF is easier / more maintainable. Pull Request resolved: #1769 Reviewed By: xuzhao9, cpuhrsch Differential Revision: D47766556 Pulled By: msaroufim fbshipit-source-id: 8393776222fc3508bda56c9c71e45d9812e69869
- Loading branch information
Showing
6 changed files
with
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel | ||
from torchbenchmark.tasks import SPEECH | ||
import torch | ||
|
||
class Model(HuggingFaceModel): | ||
task = SPEECH.RECOGNITION | ||
DEFAULT_EVAL_BSIZE = 8 | ||
DEFAULT_EVAL_CUDA_PRECISION = "fp16" | ||
|
||
def __init__(self, test, device, jit=False, batch_size=None, extra_args=[]): | ||
super().__init__(name="hf_Whisper", test=test, device=device, jit=jit, batch_size=batch_size, extra_args=extra_args) | ||
self.feature_size = 80 | ||
self.sequence_length = 3000 | ||
self.input_features = torch.randn(size=(self.batch_size, self.feature_size, self.sequence_length),device=self.device) | ||
self.example_inputs = {"input_features": self.input_features.to(self.device), "input_ids" : self.input_features.to(self.device)} | ||
self.model.to(self.device) | ||
|
||
def train(self): | ||
raise NotImplementedError("Training is not implemented.") | ||
|
||
def eval(self): | ||
self.model.eval() | ||
with torch.no_grad(): | ||
self.model(self.example_inputs["input_ids"]) | ||
|
||
def enable_fp16_half(self): | ||
self.model.half() | ||
self.example_inputs = {"input_features": self.input_features.half().to(self.device), "input_ids" : self.input_features.half().to(self.device)} |
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,13 @@ | ||
import subprocess | ||
import sys | ||
import os | ||
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model | ||
|
||
def pip_install_requirements(): | ||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt']) | ||
|
||
if __name__ == '__main__': | ||
pip_install_requirements() | ||
patch_transformers() | ||
model_name = os.path.basename(os.path.dirname(os.path.abspath(__file__))) | ||
cache_model(model_name) |
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,11 @@ | ||
devices: | ||
NVIDIA A100-SXM4-40GB: | ||
eval_batch_size: 8 | ||
eval_benchmark: false | ||
eval_deterministic: false | ||
eval_nograd: true | ||
not_implemented: | ||
- jit: true | ||
- device: cpu | ||
train_benchmark: false | ||
train_deterministic: false |
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 @@ | ||
numba |
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