kernels-bot commited on
Commit
7e6357e
·
verified ·
1 Parent(s): 91ac63d

Uploaded using `kernel-builder`.

Browse files
Files changed (25) hide show
  1. .gitattributes +6 -0
  2. build/torch210-cxx11-cpu-x86_64-linux/_ops.py +3 -3
  3. build/torch210-cxx11-cpu-x86_64-linux/{_rmsnorm_cpu_86f75d9.abi3.so → _rmsnorm_cpu_73e36c1.abi3.so} +1 -1
  4. build/torch210-cxx11-cpu-x86_64-linux/metadata.json +1 -1
  5. build/torch210-cxx11-xpu20253-x86_64-linux/_ops.py +3 -3
  6. build/torch210-cxx11-xpu20253-x86_64-linux/{_rmsnorm_xpu_86f75d9.abi3.so → _rmsnorm_xpu_73e36c1.abi3.so} +1 -1
  7. build/torch210-cxx11-xpu20253-x86_64-linux/metadata.json +1 -1
  8. build/torch211-cxx11-cpu-x86_64-linux/_ops.py +3 -3
  9. build/torch211-cxx11-cpu-x86_64-linux/{_rmsnorm_cpu_86f75d9.abi3.so → _rmsnorm_cpu_73e36c1.abi3.so} +1 -1
  10. build/torch211-cxx11-cpu-x86_64-linux/metadata.json +1 -1
  11. build/torch211-cxx11-xpu20253-x86_64-linux/_ops.py +3 -3
  12. build/torch211-cxx11-xpu20253-x86_64-linux/{_rmsnorm_xpu_86f75d9.abi3.so → _rmsnorm_xpu_73e36c1.abi3.so} +1 -1
  13. build/torch211-cxx11-xpu20253-x86_64-linux/metadata.json +1 -1
  14. build/torch212-cxx11-cpu-x86_64-linux/__init__.py +27 -0
  15. build/torch212-cxx11-cpu-x86_64-linux/_ops.py +9 -0
  16. build/torch212-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_73e36c1.abi3.so +3 -0
  17. build/torch212-cxx11-cpu-x86_64-linux/layers.py +59 -0
  18. build/torch212-cxx11-cpu-x86_64-linux/metadata.json +10 -0
  19. build/torch212-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py +26 -0
  20. build/torch212-cxx11-xpu20253-x86_64-linux/__init__.py +27 -0
  21. build/torch212-cxx11-xpu20253-x86_64-linux/_ops.py +9 -0
  22. build/torch212-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_73e36c1.abi3.so +3 -0
  23. build/torch212-cxx11-xpu20253-x86_64-linux/layers.py +59 -0
  24. build/torch212-cxx11-xpu20253-x86_64-linux/metadata.json +10 -0
  25. build/torch212-cxx11-xpu20253-x86_64-linux/rmsnorm/__init__.py +26 -0
.gitattributes CHANGED
@@ -112,3 +112,9 @@ build/torch210-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_86f75d9.abi3.so filter=lfs di
112
  build/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
113
  build/torch211-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
114
  build/torch211-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
112
  build/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
113
  build/torch211-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
114
  build/torch211-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
115
+ build/torch210-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_73e36c1.abi3.so filter=lfs diff=lfs merge=lfs -text
116
+ build/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_73e36c1.abi3.so filter=lfs diff=lfs merge=lfs -text
117
+ build/torch211-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_73e36c1.abi3.so filter=lfs diff=lfs merge=lfs -text
118
+ build/torch211-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_73e36c1.abi3.so filter=lfs diff=lfs merge=lfs -text
119
+ build/torch212-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_73e36c1.abi3.so filter=lfs diff=lfs merge=lfs -text
120
+ build/torch212-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_73e36c1.abi3.so filter=lfs diff=lfs merge=lfs -text
build/torch210-cxx11-cpu-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _rmsnorm_cpu_86f75d9
3
- ops = torch.ops._rmsnorm_cpu_86f75d9
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_rmsnorm_cpu_86f75d9::{op_name}"
 
1
  import torch
2
+ from . import _rmsnorm_cpu_73e36c1
3
+ ops = torch.ops._rmsnorm_cpu_73e36c1
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_rmsnorm_cpu_73e36c1::{op_name}"
build/torch210-cxx11-cpu-x86_64-linux/{_rmsnorm_cpu_86f75d9.abi3.so → _rmsnorm_cpu_73e36c1.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:af31d325611541e39a777f6fe6f9cf68859032778b127ea1be664be6215e2f79
3
  size 2006072
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d52ba4cfeeff591a007c8a63c1b6843911c2f546a19d0f2943cd2e7cd817fda
3
  size 2006072
build/torch210-cxx11-cpu-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "rmsnorm",
3
- "id": "_rmsnorm_cpu_86f75d9",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "rmsnorm",
3
+ "id": "_rmsnorm_cpu_73e36c1",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
build/torch210-cxx11-xpu20253-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _rmsnorm_xpu_86f75d9
3
- ops = torch.ops._rmsnorm_xpu_86f75d9
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_rmsnorm_xpu_86f75d9::{op_name}"
 
1
  import torch
2
+ from . import _rmsnorm_xpu_73e36c1
3
+ ops = torch.ops._rmsnorm_xpu_73e36c1
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_rmsnorm_xpu_73e36c1::{op_name}"
build/torch210-cxx11-xpu20253-x86_64-linux/{_rmsnorm_xpu_86f75d9.abi3.so → _rmsnorm_xpu_73e36c1.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:72c4bd9a55799b5dea42e7a037311d56332777022b30308543e5b27cc843016a
3
  size 104793360
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa3fc4f25854f9ceface6ad5b43d71fc72b70c499a2697a2299a914e6e4558fc
3
  size 104793360
build/torch210-cxx11-xpu20253-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "rmsnorm",
3
- "id": "_rmsnorm_xpu_86f75d9",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "rmsnorm",
3
+ "id": "_rmsnorm_xpu_73e36c1",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
build/torch211-cxx11-cpu-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _rmsnorm_cpu_86f75d9
3
- ops = torch.ops._rmsnorm_cpu_86f75d9
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_rmsnorm_cpu_86f75d9::{op_name}"
 
1
  import torch
2
+ from . import _rmsnorm_cpu_73e36c1
3
+ ops = torch.ops._rmsnorm_cpu_73e36c1
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_rmsnorm_cpu_73e36c1::{op_name}"
build/torch211-cxx11-cpu-x86_64-linux/{_rmsnorm_cpu_86f75d9.abi3.so → _rmsnorm_cpu_73e36c1.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:24197012635d9e36ff85244548a5312b8de99255668d4737fe91dd6e8710aa71
3
  size 2001976
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3700ca595a1f3d7a5ef0198c894d3f53d56b1b27a539d66d4e012530d6a29067
3
  size 2001976
build/torch211-cxx11-cpu-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "rmsnorm",
3
- "id": "_rmsnorm_cpu_86f75d9",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "rmsnorm",
3
+ "id": "_rmsnorm_cpu_73e36c1",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
build/torch211-cxx11-xpu20253-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _rmsnorm_xpu_86f75d9
3
- ops = torch.ops._rmsnorm_xpu_86f75d9
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_rmsnorm_xpu_86f75d9::{op_name}"
 
1
  import torch
2
+ from . import _rmsnorm_xpu_73e36c1
3
+ ops = torch.ops._rmsnorm_xpu_73e36c1
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_rmsnorm_xpu_73e36c1::{op_name}"
build/torch211-cxx11-xpu20253-x86_64-linux/{_rmsnorm_xpu_86f75d9.abi3.so → _rmsnorm_xpu_73e36c1.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2b6851a464bb933aff59903c62ffe9c02692cabf05cf6945b56606bb4b48c169
3
  size 104793120
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:858f966761b8440445b8a77b7b2e1dd91d080ae094b80f2c904b271014c275ac
3
  size 104793120
build/torch211-cxx11-xpu20253-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "rmsnorm",
3
- "id": "_rmsnorm_xpu_86f75d9",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "rmsnorm",
3
+ "id": "_rmsnorm_xpu_73e36c1",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
build/torch212-cxx11-cpu-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from . import layers
2
+
3
+ from ._ops import ops
4
+
5
+
6
+ def apply_rms_norm(input, weight, eps):
7
+ # ops.apply_rms_norm returns [output, rstd]
8
+ return ops.apply_rms_norm(
9
+ input,
10
+ weight,
11
+ eps,
12
+ )[0]
13
+
14
+ def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
15
+ return ops.apply_rms_norm_backward(
16
+ grad_output,
17
+ input,
18
+ weight,
19
+ output,
20
+ rstd,
21
+ eps,
22
+ input_requires_grad,
23
+ weight_requires_grad
24
+ )
25
+
26
+ __all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
27
+
build/torch212-cxx11-cpu-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _rmsnorm_cpu_73e36c1
3
+ ops = torch.ops._rmsnorm_cpu_73e36c1
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_rmsnorm_cpu_73e36c1::{op_name}"
build/torch212-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_73e36c1.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1023d09acad9f23cbf9759bf5b8d83455d103465ae6f9414f8dea65335967f1f
3
+ size 2002016
build/torch212-cxx11-cpu-x86_64-linux/layers.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from ._ops import ops
3
+
4
+ class RMSNormFunction(torch.autograd.Function):
5
+ @staticmethod
6
+ def forward(ctx, hidden_states, weight, variance_epsilon):
7
+ ctx.variance_epsilon = variance_epsilon
8
+ output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
9
+ ctx.save_for_backward(hidden_states, weight, output, rstd)
10
+ return output
11
+
12
+ @staticmethod
13
+ def backward(ctx, grad_output):
14
+ hidden_states, weight, output, rstd = ctx.saved_tensors
15
+ grads = ops.apply_rms_norm_backward(
16
+ grad_output,
17
+ hidden_states,
18
+ weight,
19
+ output,
20
+ rstd,
21
+ ctx.variance_epsilon,
22
+ ctx.needs_input_grad[0],
23
+ ctx.needs_input_grad[1]
24
+ )
25
+ return grads[0], grads[1], None
26
+
27
+ class RMSNorm(torch.nn.Module):
28
+ """
29
+ RMSNorm module that uses the optimized LigerRMSNormFunction.
30
+
31
+ Args:
32
+ hidden_size (int): The size of the hidden dimension.
33
+ eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
34
+ offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
35
+ casting_mode (str, optional): The casting mode to use. Defaults to "llama".
36
+ in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
37
+ """
38
+
39
+
40
+ weight: torch.Tensor
41
+ variance_epsilon: float
42
+
43
+ def forward(self, hidden_states):
44
+ """
45
+ Apply RMS normalization to the input tensor.
46
+
47
+ Args:
48
+ hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
49
+
50
+ Returns:
51
+ torch.Tensor: Normalized tensor of the same shape as input
52
+ """
53
+ return RMSNormFunction.apply(
54
+ hidden_states,
55
+ self.weight,
56
+ self.variance_epsilon,
57
+ )
58
+
59
+ __all__ = ["RMSNorm"]
build/torch212-cxx11-cpu-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "rmsnorm",
3
+ "id": "_rmsnorm_cpu_73e36c1",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cpu"
9
+ }
10
+ }
build/torch212-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
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/torch212-cxx11-xpu20253-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from . import layers
2
+
3
+ from ._ops import ops
4
+
5
+
6
+ def apply_rms_norm(input, weight, eps):
7
+ # ops.apply_rms_norm returns [output, rstd]
8
+ return ops.apply_rms_norm(
9
+ input,
10
+ weight,
11
+ eps,
12
+ )[0]
13
+
14
+ def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
15
+ return ops.apply_rms_norm_backward(
16
+ grad_output,
17
+ input,
18
+ weight,
19
+ output,
20
+ rstd,
21
+ eps,
22
+ input_requires_grad,
23
+ weight_requires_grad
24
+ )
25
+
26
+ __all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
27
+
build/torch212-cxx11-xpu20253-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _rmsnorm_xpu_73e36c1
3
+ ops = torch.ops._rmsnorm_xpu_73e36c1
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_rmsnorm_xpu_73e36c1::{op_name}"
build/torch212-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_73e36c1.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d55df4078446cac9a2915d965ffd06ae4d4c812a8ca3530dd80044a4d1f45b42
3
+ size 104793048
build/torch212-cxx11-xpu20253-x86_64-linux/layers.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from ._ops import ops
3
+
4
+ class RMSNormFunction(torch.autograd.Function):
5
+ @staticmethod
6
+ def forward(ctx, hidden_states, weight, variance_epsilon):
7
+ ctx.variance_epsilon = variance_epsilon
8
+ output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
9
+ ctx.save_for_backward(hidden_states, weight, output, rstd)
10
+ return output
11
+
12
+ @staticmethod
13
+ def backward(ctx, grad_output):
14
+ hidden_states, weight, output, rstd = ctx.saved_tensors
15
+ grads = ops.apply_rms_norm_backward(
16
+ grad_output,
17
+ hidden_states,
18
+ weight,
19
+ output,
20
+ rstd,
21
+ ctx.variance_epsilon,
22
+ ctx.needs_input_grad[0],
23
+ ctx.needs_input_grad[1]
24
+ )
25
+ return grads[0], grads[1], None
26
+
27
+ class RMSNorm(torch.nn.Module):
28
+ """
29
+ RMSNorm module that uses the optimized LigerRMSNormFunction.
30
+
31
+ Args:
32
+ hidden_size (int): The size of the hidden dimension.
33
+ eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
34
+ offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
35
+ casting_mode (str, optional): The casting mode to use. Defaults to "llama".
36
+ in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
37
+ """
38
+
39
+
40
+ weight: torch.Tensor
41
+ variance_epsilon: float
42
+
43
+ def forward(self, hidden_states):
44
+ """
45
+ Apply RMS normalization to the input tensor.
46
+
47
+ Args:
48
+ hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
49
+
50
+ Returns:
51
+ torch.Tensor: Normalized tensor of the same shape as input
52
+ """
53
+ return RMSNormFunction.apply(
54
+ hidden_states,
55
+ self.weight,
56
+ self.variance_epsilon,
57
+ )
58
+
59
+ __all__ = ["RMSNorm"]
build/torch212-cxx11-xpu20253-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "rmsnorm",
3
+ "id": "_rmsnorm_xpu_73e36c1",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "xpu"
9
+ }
10
+ }
build/torch212-cxx11-xpu20253-x86_64-linux/rmsnorm/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
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")))