summaryrefslogtreecommitdiff
path: root/aten
diff options
context:
space:
mode:
authorShen Li <shenli@fb.com>2019-01-19 22:58:54 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-01-19 23:01:31 -0800
commit898329c3f93401f731eac41bbd6e9dffa0cc7a85 (patch)
tree5594656d8c69fe19dad26bfcaee978608a85d022 /aten
parent1fb6b431a3f0938bf133e1319cacb33bc2492558 (diff)
downloadpytorch-898329c3f93401f731eac41bbd6e9dffa0cc7a85.tar.gz
pytorch-898329c3f93401f731eac41bbd6e9dffa0cc7a85.tar.bz2
pytorch-898329c3f93401f731eac41bbd6e9dffa0cc7a85.zip
Unify device() return type in Stream, Event, and Tensor (#16150)
Summary: Addresses one future work item in #15937 Pull Request resolved: https://github.com/pytorch/pytorch/pull/16150 Differential Revision: D13732299 Pulled By: mrshenli fbshipit-source-id: 4d0b35df573a3bf92dea6e2e7eb42fe8bac77b18
Diffstat (limited to 'aten')
-rw-r--r--aten/src/ATen/cuda/CUDAEvent.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/aten/src/ATen/cuda/CUDAEvent.h b/aten/src/ATen/cuda/CUDAEvent.h
index 1b14685b3c..53eadd4459 100644
--- a/aten/src/ATen/cuda/CUDAEvent.h
+++ b/aten/src/ATen/cuda/CUDAEvent.h
@@ -72,8 +72,12 @@ struct AT_CUDA_API CUDAEvent {
return left.event_ < right.event_;
}
- at::Device device() const {
- return at::Device(at::kCUDA, device_index_);
+ optional<at::Device> device() const {
+ if (is_created_) {
+ return at::Device(at::kCUDA, device_index_);
+ } else {
+ return {};
+ }
}
bool isCreated() const { return is_created_; }