File: mps_ops.py

package info (click to toggle)
python-thinc 8.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,804 kB
  • sloc: python: 15,818; javascript: 1,554; ansic: 342; makefile: 20; sh: 13
file content (26 lines) | stat: -rw-r--r-- 581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import TYPE_CHECKING
import numpy

from .. import registry
from . import NumpyOps, Ops

if TYPE_CHECKING:
    # Type checking does not work with dynamic base classes, since MyPy cannot
    # determine against which base class to check. So, always derive from Ops
    # during type checking.
    _Ops = Ops
else:
    try:
        from thinc_apple_ops import AppleOps

        _Ops = AppleOps
    except ImportError:
        _Ops = NumpyOps


@registry.ops("MPSOps")
class MPSOps(_Ops):
    """Ops class for Metal Performance shaders."""

    name = "mps"
    xp = numpy