mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[OpenReg] Improve README.md and optimize some codes for OpenReg (#158415)
---- - add description for DSO dependencies - remove unnecessary code Pull Request resolved: https://github.com/pytorch/pytorch/pull/158415 Approved by: https://github.com/albanD
This commit is contained in:
@ -75,10 +75,20 @@ graph LR
|
||||
A --> B --> C --> D --> E
|
||||
```
|
||||
|
||||
- `_C.so`: torch\_openreg/csrc/stub.c
|
||||
- `libtorch_bindings.so`: torch\_openreg/csrc/\*.cpp
|
||||
- `libtorch_openreg.so`: csrc
|
||||
- `libopenreg.so`: third\_party/openreg
|
||||
There are 4 DSOs in torch_openreg, and the dependencies between them are as follows:
|
||||
|
||||
- `_C.so`:
|
||||
- **sources**: torch_openreg/csrc/stub.c
|
||||
- **description**: Python C module entry point.
|
||||
- `libtorch_bindings.so`: The bridging code between Python and C++ should go here.
|
||||
- **sources**: torch_openreg/csrc
|
||||
- **description**: A thin glue layer between Python and C++.
|
||||
- `libtorch_openreg.so`: All core implementations should go here.
|
||||
- **sources**: csrc
|
||||
- **description**: All core functionality, such as device runtime, operators, etc.
|
||||
- `libopenreg.so`: A DSO that uses the CPU to emulate a CUDA-like device, you can ignore it.
|
||||
- **sources**: third_party/openreg
|
||||
- **description**: Provides low-level device functionality similar to libcudart.so.
|
||||
|
||||
**Key Directories**:
|
||||
|
||||
@ -155,18 +165,14 @@ print("OpenReg backend is available!")
|
||||
|
||||
device = torch.device("openreg")
|
||||
|
||||
try:
|
||||
x = torch.tensor([[1., 2.], [3., 4.]], device=device)
|
||||
y = x + 2
|
||||
print("Result y:\n", y)
|
||||
print(f"Device of y: {y.device}")
|
||||
x = torch.tensor([[1., 2.], [3., 4.]], device=device)
|
||||
y = x + 2
|
||||
print("Result y:\n", y)
|
||||
print(f"Device of y: {y.device}")
|
||||
|
||||
z = y.cpu()
|
||||
print("Result z:\n", z)
|
||||
print(f"Device of z: {z.device}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\nAn error occurred: {e}")
|
||||
z = y.cpu()
|
||||
print("Result z:\n", z)
|
||||
print(f"Device of z: {z.device}")
|
||||
```
|
||||
|
||||
## Future Plans
|
||||
|
@ -1,2 +1 @@
|
||||
torch
|
||||
pybind11
|
||||
|
@ -15,7 +15,6 @@ import torch_openreg # noqa: F401
|
||||
import torch
|
||||
from torch.serialization import safe_globals
|
||||
from torch.testing._internal.common_utils import (
|
||||
IS_LINUX,
|
||||
run_tests,
|
||||
skipIfTorchDynamo,
|
||||
skipIfXpu,
|
||||
@ -583,5 +582,4 @@ class TestOpenReg(TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if IS_LINUX:
|
||||
run_tests()
|
||||
run_tests()
|
||||
|
Reference in New Issue
Block a user