Kernels

Add Metal (Apple Silicon) build variants

#6
build/torch210-metal-aarch64-darwin/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from ._custom_ops import rotary_embedding
2
+ from ._ops import ops
3
+
4
+ __all__ = [
5
+ "ops",
6
+ "rotary_embedding",
7
+ ]
build/torch210-metal-aarch64-darwin/_custom_ops.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+
3
+ import torch
4
+
5
+ from ._ops import ops
6
+
7
+
8
+ def rotary_embedding(
9
+ positions: torch.Tensor,
10
+ query: torch.Tensor,
11
+ key: Optional[torch.Tensor],
12
+ head_size: int,
13
+ cos_sin_cache: torch.Tensor,
14
+ is_neox: bool,
15
+ ) -> None:
16
+ ops.rotary_embedding(positions, query, key, head_size, cos_sin_cache,
17
+ is_neox)
build/torch210-metal-aarch64-darwin/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _rotary_embedding_metal_dd92cff_dirty
3
+ ops = torch.ops._rotary_embedding_metal_dd92cff_dirty
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_rotary_embedding_metal_dd92cff_dirty::{op_name}"
build/torch210-metal-aarch64-darwin/_rotary_embedding_metal_dd92cff_dirty.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1315885641ce38b81769348fb5fa8cf22fe6789b4e13c69b8d52bca26619fcef
3
+ size 124448
build/torch210-metal-aarch64-darwin/metadata.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "python-depends": []
3
+ }
build/torch210-metal-aarch64-darwin/rotary_embedding/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import sys
3
+
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch29-metal-aarch64-darwin/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from ._custom_ops import rotary_embedding
2
+ from ._ops import ops
3
+
4
+ __all__ = [
5
+ "ops",
6
+ "rotary_embedding",
7
+ ]
build/torch29-metal-aarch64-darwin/_custom_ops.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+
3
+ import torch
4
+
5
+ from ._ops import ops
6
+
7
+
8
+ def rotary_embedding(
9
+ positions: torch.Tensor,
10
+ query: torch.Tensor,
11
+ key: Optional[torch.Tensor],
12
+ head_size: int,
13
+ cos_sin_cache: torch.Tensor,
14
+ is_neox: bool,
15
+ ) -> None:
16
+ ops.rotary_embedding(positions, query, key, head_size, cos_sin_cache,
17
+ is_neox)
build/torch29-metal-aarch64-darwin/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _rotary_embedding_metal_dd92cff_dirty
3
+ ops = torch.ops._rotary_embedding_metal_dd92cff_dirty
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_rotary_embedding_metal_dd92cff_dirty::{op_name}"
build/torch29-metal-aarch64-darwin/_rotary_embedding_metal_dd92cff_dirty.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a0d370b58113ffecdf6fc75e8b347914a4906e4ede814eb0dbb26b5a88ae43a
3
+ size 123376
build/torch29-metal-aarch64-darwin/metadata.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "python-depends": []
3
+ }
build/torch29-metal-aarch64-darwin/rotary_embedding/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import sys
3
+
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))