Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into maintenance/merge…
Browse files Browse the repository at this point in the history
…-master-20240212
  • Loading branch information
danieldk committed Feb 12, 2024
2 parents 40d4148 + 3aae298 commit c1c72f2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ jobs:
- name: Run mypy
run: python -m mypy thinc --no-implicit-reexport
if: matrix.python_version != '3.6'
if: |
matrix.python_version != '3.6' &&
matrix.python_version != '3.7'
- name: Delete source directory
run: rm -rf thinc
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pytest-cov>=2.7.0,<5.0.0
coverage>=5.0.0,<8.0.0
mock>=2.0.0,<3.0.0
flake8>=3.5.0,<3.6.0
mypy>=1.0.0,<1.1.0; python_version >= "3.7"
mypy>=1.5.0,<1.6.0; platform_machine != "aarch64" and python_version >= "3.8"
types-mock>=0.1.1
types-contextvars>=0.1.2; python_version < "3.7"
types-dataclasses>=0.1.3; python_version < "3.7"
Expand Down
4 changes: 2 additions & 2 deletions thinc/backends/cupy_ops.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy

from .. import registry
from ..compat import cupy, cupyx
from ..compat import cublas, cupy, cupyx
from ..types import DeviceTypes
from ..util import (
is_cupy_array,
Expand Down Expand Up @@ -257,7 +257,7 @@ def clip_gradient(self, gradient, threshold):
# implementation.
def frobenius_norm(X):
X_vec = X.reshape(-1)
return cupy.cublas.nrm2(X_vec)
return cublas.nrm2(X_vec)

grad_norm = cupy.maximum(frobenius_norm(gradient), 1e-12)
gradient *= cupy.minimum(threshold, grad_norm) / grad_norm
Expand Down
3 changes: 3 additions & 0 deletions thinc/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

try: # pragma: no cover
import cupy
import cupy.cublas
import cupyx

has_cupy = True
cublas = cupy.cublas
cupy_version = Version(cupy.__version__)
try:
cupy.cuda.runtime.getDeviceCount()
Expand All @@ -20,6 +22,7 @@
else:
cupy_from_dlpack = cupy.fromDlpack
except (ImportError, AttributeError):
cublas = None
cupy = None
cupyx = None
cupy_version = Version("0.0.0")
Expand Down
2 changes: 1 addition & 1 deletion thinc/shims/torchscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TorchScriptShim(PyTorchShim):

def __init__(
self,
model: Optional["torch.ScriptModule"],
model: Optional["torch.jit.ScriptModule"],
config=None,
optimizer: Any = None,
mixed_precision: bool = False,
Expand Down
1 change: 0 additions & 1 deletion thinc/tests/layers/test_basic_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def get_shuffled_batches(Xs, Ys, batch_size):
yield list(batch_X), list(batch_Y)


@pytest.mark.slow
@pytest.mark.parametrize(
("depth", "width", "vector_width", "nb_epoch"), [(2, 32, 16, 5)]
)
Expand Down

0 comments on commit c1c72f2

Please sign in to comment.