Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ torch_openreg/
│ ├── OpenRegHostAllocator.cpp
│ ├── OpenRegHostAllocator.h
│ └── ...
├── pyproject.toml
├── README.md
├── setup.py
├── third_party
Expand Down Expand Up @@ -144,9 +145,8 @@ There are 4 DSOs in torch_openreg, and the dependencies between them are as foll
### Installation

```python
pip3 install -r requirements.txt

python setup.py develop/install
pip3 install --no-build-isolation -e . # for develop
pip3 install --no-build-isolation . # for install
```

### Usage Example
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[build-system]
requires = [
"setuptools",
"wheel",
"torch", # Needed by setup.py for getting include of PyTorch
]

build-backend = "setuptools.build_meta"

[project]
name = "torch_openreg"
version = "0.0.1"
description = "A minimal reference implementation of an out-of-tree backend"
readme = "README.md"
requires-python = ">=3.9"
license = { text = "BSD-3-Clause" }
authors = [{ name = "PyTorch Team", email = "packages@pytorch.org" }]
dependencies = [
"torch",
]
# Add classifiers info for making lint happy
classifiers = [
"Development Status :: 4 - Beta",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: C++",
"Programming Language :: Python :: 3 :: Only",
]

[project.urls]
Homepage = "https://pytorch.org"
Repository = "https://github.com/pytorch/pytorch"
Documentation = "https://pytorch.org/docs"
Forum = "https://discuss.pytorch.org"

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from setuptools import Extension, find_packages, setup


PACKAGE_NAME = "torch_openreg"
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
RUN_BUILD_DEPS = any(arg in {"clean", "dist_info"} for arg in sys.argv)


def get_pytorch_dir():
Expand Down Expand Up @@ -49,7 +49,7 @@ def build_deps():

class BuildClean(clean):
def run(self):
for i in ["build", "install", "torch_openreg.egg-info", "torch_openreg/lib"]:
for i in ["build", "install", "torch_openreg/lib"]:
dirs = os.path.join(BASE_DIR, i)
if os.path.exists(dirs) and os.path.isdir(dirs):
shutil.rmtree(dirs)
Expand All @@ -60,9 +60,6 @@ def run(self):
os.remove(os.path.join(dirpath, filename))


RUN_BUILD_DEPS = any(arg == "clean" for arg in sys.argv)


def main():
if not RUN_BUILD_DEPS:
build_deps()
Expand All @@ -71,27 +68,20 @@ def main():
Extension(
name="torch_openreg._C",
sources=["torch_openreg/csrc/stub.c"],
language="c",
extra_compile_args=["-g", "-Wall", "-Werror"],
libraries=["torch_bindings"],
library_dirs=[os.path.join(BASE_DIR, "torch_openreg/lib")],
extra_link_args=["-Wl,-rpath,$ORIGIN/lib"],
)
]

package_data = {PACKAGE_NAME: ["lib/*.so*"]}
package_data = {"torch_openreg": ["lib/*.so*"]}

setup(
name=PACKAGE_NAME,
version="0.0.1",
author="PyTorch Core Team",
description="Example for PyTorch out of tree registration",
packages=find_packages(exclude=("test",)),
packages=find_packages(),
package_data=package_data,
install_requires=[
"torch",
],
ext_modules=ext_modules,
python_requires=">=3.8",
cmdclass={
"clean": BuildClean, # type: ignore[misc]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import torch

import torch_openreg._C # type: ignore[misc]
import torch_openreg.openreg

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import torch

import torch_openreg._C # type: ignore[misc]


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import torch

import torch_openreg._C # type: ignore[misc]

from . import _lazy_init, current_device, device_count
Expand Down
Loading