-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Rishit-dagli/unit-tests
Add Unit Tests
- Loading branch information
Showing
8 changed files
with
69 additions
and
6 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,25 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tensorflow==2.7.0 einops rotary-embedding-tensorflow | ||
- name: Run Tests | ||
run: | | ||
python -m fast_transformer.test_fast_transformer |
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,30 @@ | ||
import numpy as np | ||
import tensorflow as tf | ||
|
||
from fast_transformer.fast_transformer import FastTransformer | ||
|
||
|
||
class FastTransformerTest(tf.test.TestCase): | ||
def setUp(self): | ||
super(FastTransformerTest, self).setUp() | ||
|
||
mask = tf.ones([1, 4096], dtype=tf.bool) | ||
self.model = FastTransformer( | ||
num_tokens=20000, | ||
dim=512, | ||
depth=2, | ||
max_seq_len=4096, | ||
absolute_pos_emb=True, | ||
mask=mask, | ||
) | ||
|
||
def test_shape_and_rank(self): | ||
inputs = tf.experimental.numpy.random.randint(0, 20000, (1, 4096)) | ||
outputs = self.model(inputs) | ||
|
||
self.assertEqual(tf.rank(outputs), 3) | ||
self.assertShapeEqual(np.zeros((1, 4096, 20000)), outputs) | ||
|
||
|
||
if __name__ == "__main__": | ||
tf.test.main() |
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.1.0" | ||
__version__ = "0.2.0" |
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