-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for torch.cuda and c10::cuda APIs
- Loading branch information
1 parent
c0852a0
commit ccbecca
Showing
6 changed files
with
313 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,58 @@ | ||
from torch import xpu | ||
|
||
cuda_ver = torch.version.xpu | ||
|
||
#init | ||
torch.xpu.init() | ||
xpu.init() | ||
is_init = torch.xpu.is_initialized() | ||
is_init = xpu.is_initialized() | ||
|
||
# device APIs | ||
devs = torch.xpu.device_count() | ||
devs = xpu.device_count() | ||
|
||
dev = torch.xpu.current_device() | ||
dev = xpu.current_device() | ||
|
||
torch.xpu.set_device(dev) | ||
xpu.set_device(dev) | ||
|
||
d_props = torch.xpu.get_device_properties(dev) | ||
d_props = xpu.get_device_properties(dev) | ||
|
||
curr_d_name = torch.xpu.get_device_name() | ||
curr_d_name = xpu.get_device_name() | ||
d_name = torch.xpu.get_device_name(dev) | ||
d_name = xpu.get_device_name(dev) | ||
|
||
d_cap = torch.xpu.get_device_capability() | ||
d_cap = xpu.get_device_capability() | ||
d0_cap = torch.xpu.get_device_capability(devs[0]) | ||
d0_cap = xpu.get_device_capability(devs[0]) | ||
|
||
dev_of_obj = torch.xpu.device_of(obj) | ||
dev_of_obj = xpu.device_of(obj) | ||
|
||
arch_list = [''] | ||
arch_list = [''] | ||
|
||
cuda_ver = torch.version.xpu | ||
torch.xpu.synchronize() | ||
xpu.synchronize() | ||
torch.xpu.synchronize(dev) | ||
xpu.synchronize(dev) | ||
|
||
# stream APIs | ||
curr_st = torch.xpu.current_stream() | ||
curr_st = xpu.current_stream() | ||
curr_d_st = torch.xpu.current_stream(dev) | ||
curr_d_st = xpu.current_stream(dev) | ||
|
||
st = torch.xpu.StreamContext(curr_st) | ||
st = xpu.StreamContext(curr_st) | ||
|
||
stS = torch.xpu.stream(st) | ||
stS = xpu.stream(st) | ||
|
||
torch.xpu.set_stream(st) | ||
xpu.set_stream(st) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,58 @@ | ||
from torch import cuda | ||
|
||
cuda_ver = torch.version.cuda | ||
|
||
#init | ||
torch.cuda.init() | ||
cuda.init() | ||
is_init = torch.cuda.is_initialized() | ||
is_init = cuda.is_initialized() | ||
|
||
# device APIs | ||
devs = torch.cuda.device_count() | ||
devs = cuda.device_count() | ||
|
||
dev = torch.cuda.current_device() | ||
dev = cuda.current_device() | ||
|
||
torch.cuda.set_device(dev) | ||
cuda.set_device(dev) | ||
|
||
d_props = torch.cuda.get_device_properties(dev) | ||
d_props = cuda.get_device_properties(dev) | ||
|
||
curr_d_name = torch.cuda.get_device_name() | ||
curr_d_name = cuda.get_device_name() | ||
d_name = torch.cuda.get_device_name(dev) | ||
d_name = cuda.get_device_name(dev) | ||
|
||
d_cap = torch.cuda.get_device_capability() | ||
d_cap = cuda.get_device_capability() | ||
d0_cap = torch.cuda.get_device_capability(devs[0]) | ||
d0_cap = cuda.get_device_capability(devs[0]) | ||
|
||
dev_of_obj = torch.cuda.device_of(obj) | ||
dev_of_obj = cuda.device_of(obj) | ||
|
||
arch_list = torch.cuda.get_arch_list() | ||
arch_list = cuda.get_arch_list() | ||
|
||
cuda_ver = torch.version.cuda | ||
torch.cuda.synchronize() | ||
cuda.synchronize() | ||
torch.cuda.synchronize(dev) | ||
cuda.synchronize(dev) | ||
|
||
# stream APIs | ||
curr_st = torch.cuda.current_stream() | ||
curr_st = cuda.current_stream() | ||
curr_d_st = torch.cuda.current_stream(dev) | ||
curr_d_st = cuda.current_stream(dev) | ||
|
||
st = torch.cuda.StreamContext(curr_st) | ||
st = cuda.StreamContext(curr_st) | ||
|
||
stS = torch.cuda.stream(st) | ||
stS = cuda.stream(st) | ||
|
||
torch.cuda.set_stream(st) | ||
cuda.set_stream(st) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
clang/test/dpct/pytorch/pytorch_cuda_inc/c10/cuda/CUDAFunctions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <cmath> | ||
|
||
namespace c10 { | ||
using DeviceIndex = int8_t; | ||
|
||
namespace cuda { | ||
DeviceIndex device_count(); | ||
DeviceIndex device_count_ensure_non_zero(); | ||
DeviceIndex current_device(); | ||
void set_device(DeviceIndex device); | ||
DeviceIndex ExchangeDevice(DeviceIndex device); | ||
DeviceIndex MaybeExchangeDevice(DeviceIndex to_device); | ||
} // namespace cuda | ||
} // namespace c10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.