Instructions to use kernels-community/relu with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use kernels-community/relu with Kernels:
# !pip install kernels from kernels import get_kernel kernel = get_kernel("kernels-community/relu") - Notebooks
- Google Colab
- Kaggle
Uploaded using `kernel-builder`.
Browse files- .gitattributes +12 -0
- build/torch210-cxx11-cpu-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cpu-aarch64-linux/{_relu_cpu_86f75d9.abi3.so → _relu_cpu_c835f43.abi3.so} +1 -1
- build/torch210-cxx11-cpu-aarch64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu126-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu126-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so} +1 -1
- build/torch210-cxx11-cu126-aarch64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu128-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu128-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so} +1 -1
- build/torch210-cxx11-cu128-aarch64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu130-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so} +1 -1
- build/torch210-cxx11-cu130-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cpu-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cpu-aarch64-linux/{_relu_cpu_86f75d9.abi3.so → _relu_cpu_c835f43.abi3.so} +1 -1
- build/torch211-cxx11-cpu-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu126-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu126-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so} +1 -1
- build/torch211-cxx11-cu126-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu128-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu128-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so} +1 -1
- build/torch211-cxx11-cu128-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu130-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so} +1 -1
- build/torch211-cxx11-cu130-aarch64-linux/metadata.json +1 -1
- build/torch212-cxx11-cpu-aarch64-linux/__init__.py +16 -0
- build/torch212-cxx11-cpu-aarch64-linux/_ops.py +9 -0
- build/torch212-cxx11-cpu-aarch64-linux/_relu_cpu_c835f43.abi3.so +3 -0
- build/torch212-cxx11-cpu-aarch64-linux/layers/__init__.py +11 -0
- build/torch212-cxx11-cpu-aarch64-linux/metadata.json +10 -0
- build/torch212-cxx11-cpu-aarch64-linux/relu/__init__.py +26 -0
- build/torch212-cxx11-cu126-aarch64-linux/__init__.py +16 -0
- build/torch212-cxx11-cu126-aarch64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu126-aarch64-linux/_relu_cuda_c835f43.abi3.so +3 -0
- build/torch212-cxx11-cu126-aarch64-linux/layers/__init__.py +11 -0
- build/torch212-cxx11-cu126-aarch64-linux/metadata.json +20 -0
- build/torch212-cxx11-cu126-aarch64-linux/relu/__init__.py +26 -0
- build/torch212-cxx11-cu130-aarch64-linux/__init__.py +16 -0
- build/torch212-cxx11-cu130-aarch64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu130-aarch64-linux/_relu_cuda_c835f43.abi3.so +3 -0
- build/torch212-cxx11-cu130-aarch64-linux/layers/__init__.py +11 -0
- build/torch212-cxx11-cu130-aarch64-linux/metadata.json +21 -0
- build/torch212-cxx11-cu130-aarch64-linux/relu/__init__.py +26 -0
- build/torch212-cxx11-cu132-aarch64-linux/__init__.py +16 -0
- build/torch212-cxx11-cu132-aarch64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu132-aarch64-linux/_relu_cuda_c835f43.abi3.so +3 -0
- build/torch212-cxx11-cu132-aarch64-linux/layers/__init__.py +11 -0
- build/torch212-cxx11-cu132-aarch64-linux/metadata.json +21 -0
- build/torch212-cxx11-cu132-aarch64-linux/relu/__init__.py +26 -0
.gitattributes
CHANGED
|
@@ -573,3 +573,15 @@ build/torch211-cxx11-cu130-x86_64-linux/_relu_cuda_86f75d9.abi3.so filter=lfs di
|
|
| 573 |
build/torch211-cxx11-rocm71-x86_64-linux/_relu_rocm_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 574 |
build/torch211-cxx11-rocm72-x86_64-linux/_relu_rocm_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 575 |
build/torch211-cxx11-xpu20253-x86_64-linux/_relu_xpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 573 |
build/torch211-cxx11-rocm71-x86_64-linux/_relu_rocm_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 574 |
build/torch211-cxx11-rocm72-x86_64-linux/_relu_rocm_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 575 |
build/torch211-cxx11-xpu20253-x86_64-linux/_relu_xpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 576 |
+
build/torch210-cxx11-cpu-aarch64-linux/_relu_cpu_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 577 |
+
build/torch210-cxx11-cu126-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 578 |
+
build/torch210-cxx11-cu128-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 579 |
+
build/torch210-cxx11-cu130-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 580 |
+
build/torch211-cxx11-cpu-aarch64-linux/_relu_cpu_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 581 |
+
build/torch211-cxx11-cu126-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 582 |
+
build/torch211-cxx11-cu128-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 583 |
+
build/torch211-cxx11-cu130-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 584 |
+
build/torch212-cxx11-cpu-aarch64-linux/_relu_cpu_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 585 |
+
build/torch212-cxx11-cu126-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 586 |
+
build/torch212-cxx11-cu130-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 587 |
+
build/torch212-cxx11-cu132-aarch64-linux/_relu_cuda_c835f43.abi3.so filter=lfs diff=lfs merge=lfs -text
|
build/torch210-cxx11-cpu-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cpu_c835f43
|
| 3 |
+
ops = torch.ops._relu_cpu_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cpu_c835f43::{op_name}"
|
build/torch210-cxx11-cpu-aarch64-linux/{_relu_cpu_86f75d9.abi3.so → _relu_cpu_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2025352
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78b2891eacc497c5b1a0f3c3979b3eace2e1e825f0f0dcad6bc867876c428578
|
| 3 |
size 2025352
|
build/torch210-cxx11-cpu-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cpu_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu126-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch210-cxx11-cu126-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2103912
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d40b75d43393daf4096ea7786d113d714d5d9d9311209fcaee0c8a5c15823e9
|
| 3 |
size 2103912
|
build/torch210-cxx11-cu126-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu128-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch210-cxx11-cu128-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2235240
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ce6430752d3b59bdf2c8c62796744f9b231656597320b072fd117e3690815f2
|
| 3 |
size 2235240
|
build/torch210-cxx11-cu128-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu130-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch210-cxx11-cu130-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2237576
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5c975f35d1fe9b9d59bbe8d1737bc0ee16e4667d18509eccd4e85808832066e0
|
| 3 |
size 2237576
|
build/torch210-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cpu-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cpu_c835f43
|
| 3 |
+
ops = torch.ops._relu_cpu_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cpu_c835f43::{op_name}"
|
build/torch211-cxx11-cpu-aarch64-linux/{_relu_cpu_86f75d9.abi3.so → _relu_cpu_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2025352
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f880d1df2d972386740839edd7b372e81f96b3ec2886f1c4ea7238078aac01ab
|
| 3 |
size 2025352
|
build/torch211-cxx11-cpu-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cpu_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu126-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch211-cxx11-cu126-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2100128
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:529d53448decbdb386cab3a96834e78d676e3a001461f46876c41cd18a6c2e96
|
| 3 |
size 2100128
|
build/torch211-cxx11-cu126-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu128-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch211-cxx11-cu128-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2231464
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:566727ce4a18440b53477664ce5570632afcf29d070557d8f0a0532629058cd4
|
| 3 |
size 2231464
|
build/torch211-cxx11-cu128-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu130-aarch64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch211-cxx11-cu130-aarch64-linux/{_relu_cuda_86f75d9.abi3.so → _relu_cuda_c835f43.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2233792
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2f01a470f455175bb8f58f719b6f20d36fd9f86bf4a8ba0f9f97055ec9ccdba1
|
| 3 |
size 2233792
|
build/torch211-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch212-cxx11-cpu-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
from ._ops import ops
|
| 6 |
+
|
| 7 |
+
from . import layers
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor:
|
| 11 |
+
if out is None:
|
| 12 |
+
out = torch.empty_like(x)
|
| 13 |
+
ops.relu(out, x)
|
| 14 |
+
return out
|
| 15 |
+
|
| 16 |
+
__all__ = ["relu", "layers"]
|
build/torch212-cxx11-cpu-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _relu_cpu_c835f43
|
| 3 |
+
ops = torch.ops._relu_cpu_c835f43
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_relu_cpu_c835f43::{op_name}"
|
build/torch212-cxx11-cpu-aarch64-linux/_relu_cpu_c835f43.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c85a508c788d75aa725979af5ae17ee3abb1d12817a03b5a63d6110c6a832443
|
| 3 |
+
size 2025360
|
build/torch212-cxx11-cpu-aarch64-linux/layers/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
|
| 4 |
+
from .._ops import ops
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class ReLU(nn.Module):
|
| 8 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 9 |
+
out = torch.empty_like(x)
|
| 10 |
+
ops.relu(out, x)
|
| 11 |
+
return out
|
build/torch212-cxx11-cpu-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "relu",
|
| 3 |
+
"id": "_relu_cpu_c835f43",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cpu"
|
| 9 |
+
}
|
| 10 |
+
}
|
build/torch212-cxx11-cpu-aarch64-linux/relu/__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-cu126-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
from ._ops import ops
|
| 6 |
+
|
| 7 |
+
from . import layers
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor:
|
| 11 |
+
if out is None:
|
| 12 |
+
out = torch.empty_like(x)
|
| 13 |
+
ops.relu(out, x)
|
| 14 |
+
return out
|
| 15 |
+
|
| 16 |
+
__all__ = ["relu", "layers"]
|
build/torch212-cxx11-cu126-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch212-cxx11-cu126-aarch64-linux/_relu_cuda_c835f43.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a1b01720ae004db4e6dc10e82e27983412a380dd20ccf87503a582bfe3b8d290
|
| 3 |
+
size 2103184
|
build/torch212-cxx11-cu126-aarch64-linux/layers/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
|
| 4 |
+
from .._ops import ops
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class ReLU(nn.Module):
|
| 8 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 9 |
+
out = torch.empty_like(x)
|
| 10 |
+
ops.relu(out, x)
|
| 11 |
+
return out
|
build/torch212-cxx11-cu126-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"7.0",
|
| 11 |
+
"7.2",
|
| 12 |
+
"7.5",
|
| 13 |
+
"8.0",
|
| 14 |
+
"8.6",
|
| 15 |
+
"8.7",
|
| 16 |
+
"8.9",
|
| 17 |
+
"9.0+PTX"
|
| 18 |
+
]
|
| 19 |
+
}
|
| 20 |
+
}
|
build/torch212-cxx11-cu126-aarch64-linux/relu/__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-cu130-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
from ._ops import ops
|
| 6 |
+
|
| 7 |
+
from . import layers
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor:
|
| 11 |
+
if out is None:
|
| 12 |
+
out = torch.empty_like(x)
|
| 13 |
+
ops.relu(out, x)
|
| 14 |
+
return out
|
| 15 |
+
|
| 16 |
+
__all__ = ["relu", "layers"]
|
build/torch212-cxx11-cu130-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch212-cxx11-cu130-aarch64-linux/_relu_cuda_c835f43.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a14e05ca83bf142e19d8cdc8c862ba97c1649d8a810f4e4b27850f8d47993f9
|
| 3 |
+
size 2236848
|
build/torch212-cxx11-cu130-aarch64-linux/layers/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
|
| 4 |
+
from .._ops import ops
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class ReLU(nn.Module):
|
| 8 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 9 |
+
out = torch.empty_like(x)
|
| 10 |
+
ops.relu(out, x)
|
| 11 |
+
return out
|
build/torch212-cxx11-cu130-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0+PTX",
|
| 13 |
+
"7.5",
|
| 14 |
+
"8.0",
|
| 15 |
+
"8.6",
|
| 16 |
+
"8.7",
|
| 17 |
+
"8.9",
|
| 18 |
+
"9.0"
|
| 19 |
+
]
|
| 20 |
+
}
|
| 21 |
+
}
|
build/torch212-cxx11-cu130-aarch64-linux/relu/__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-cu132-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
from ._ops import ops
|
| 6 |
+
|
| 7 |
+
from . import layers
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor:
|
| 11 |
+
if out is None:
|
| 12 |
+
out = torch.empty_like(x)
|
| 13 |
+
ops.relu(out, x)
|
| 14 |
+
return out
|
| 15 |
+
|
| 16 |
+
__all__ = ["relu", "layers"]
|
build/torch212-cxx11-cu132-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _relu_cuda_c835f43
|
| 3 |
+
ops = torch.ops._relu_cuda_c835f43
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_relu_cuda_c835f43::{op_name}"
|
build/torch212-cxx11-cu132-aarch64-linux/_relu_cuda_c835f43.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:666f8c58a3aea1413ea75340c3fabd27330cae29ccaf5c549e8299deda92b55f
|
| 3 |
+
size 2304984
|
build/torch212-cxx11-cu132-aarch64-linux/layers/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
|
| 4 |
+
from .._ops import ops
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class ReLU(nn.Module):
|
| 8 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 9 |
+
out = torch.empty_like(x)
|
| 10 |
+
ops.relu(out, x)
|
| 11 |
+
return out
|
build/torch212-cxx11-cu132-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "relu",
|
| 3 |
+
"id": "_relu_cuda_c835f43",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0+PTX",
|
| 13 |
+
"7.5",
|
| 14 |
+
"8.0",
|
| 15 |
+
"8.6",
|
| 16 |
+
"8.7",
|
| 17 |
+
"8.9",
|
| 18 |
+
"9.0"
|
| 19 |
+
]
|
| 20 |
+
}
|
| 21 |
+
}
|
build/torch212-cxx11-cu132-aarch64-linux/relu/__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")))
|