From 023e4d55a8794e62db16b2add703904c79557618 Mon Sep 17 00:00:00 2001 From: Wonjoo Lee Date: Fri, 9 Dec 2022 00:37:16 +0000 Subject: [PATCH 1/3] Add note [Note: Re-using upstream TensorImpl] --- torch_xla/csrc/tensor_impl.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/torch_xla/csrc/tensor_impl.h b/torch_xla/csrc/tensor_impl.h index 2e76fe6e8289..76fb3d2cb0ed 100644 --- a/torch_xla/csrc/tensor_impl.h +++ b/torch_xla/csrc/tensor_impl.h @@ -8,6 +8,14 @@ namespace torch_xla { +// [Note: Re-using upstream TensorImpl] As part of the LTC migration effort, +// we tried to re-use the upstream LTCTensorImpl (torch/csrc/lazy/core/tensor_impl.h) +// instead of having our own version of XLATensorImpl. However, LTCTensorImpl defines +// its own set of hard-coded dispatch keys in its constructor and has functions that +// call this constructor. In addition, updating XLATensorImpl to extend LTCTensorImpl +// does not produce much benefit since that wouldn't remove much duplicate code. +// As a result, we decided to keep and use XLATensorImpl. + // Tensor implementation class used to be fed to the at::Tensor. // Its scope is just to handle an XLATensor. class XLATensorImpl : public c10::TensorImpl { From 14e9363c95e3355211b5ca6cbfd84249da37919a Mon Sep 17 00:00:00 2001 From: Wonjoo Lee Date: Fri, 9 Dec 2022 00:51:37 +0000 Subject: [PATCH 2/3] Run linter --- torch_xla/csrc/tensor_impl.h | 13 +++++++------ wonjoo.py | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 wonjoo.py diff --git a/torch_xla/csrc/tensor_impl.h b/torch_xla/csrc/tensor_impl.h index 76fb3d2cb0ed..8a0fa9862a6d 100644 --- a/torch_xla/csrc/tensor_impl.h +++ b/torch_xla/csrc/tensor_impl.h @@ -9,12 +9,13 @@ namespace torch_xla { // [Note: Re-using upstream TensorImpl] As part of the LTC migration effort, -// we tried to re-use the upstream LTCTensorImpl (torch/csrc/lazy/core/tensor_impl.h) -// instead of having our own version of XLATensorImpl. However, LTCTensorImpl defines -// its own set of hard-coded dispatch keys in its constructor and has functions that -// call this constructor. In addition, updating XLATensorImpl to extend LTCTensorImpl -// does not produce much benefit since that wouldn't remove much duplicate code. -// As a result, we decided to keep and use XLATensorImpl. +// we tried to re-use the upstream LTCTensorImpl +// (torch/csrc/lazy/core/tensor_impl.h) instead of having our own version of +// XLATensorImpl. However, LTCTensorImpl defines its own set of hard-coded +// dispatch keys in its constructor and has functions that call this +// constructor. In addition, updating XLATensorImpl to extend LTCTensorImpl does +// not produce much benefit since that wouldn't remove much duplicate code. As a +// result, we decided to keep and use XLATensorImpl. // Tensor implementation class used to be fed to the at::Tensor. // Its scope is just to handle an XLATensor. diff --git a/wonjoo.py b/wonjoo.py new file mode 100644 index 000000000000..2dd85fa128e3 --- /dev/null +++ b/wonjoo.py @@ -0,0 +1,5 @@ +import torch +import torch_xla + +device = "xla:0" +a_xla = torch.tensor([1, 2], device=device) From 20b44813d0044f633908368d91d826cbe9101cef Mon Sep 17 00:00:00 2001 From: Wonjoo Lee Date: Thu, 8 Dec 2022 16:57:50 -0800 Subject: [PATCH 3/3] Remove test file --- wonjoo.py | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 wonjoo.py diff --git a/wonjoo.py b/wonjoo.py deleted file mode 100644 index 2dd85fa128e3..000000000000 --- a/wonjoo.py +++ /dev/null @@ -1,5 +0,0 @@ -import torch -import torch_xla - -device = "xla:0" -a_xla = torch.tensor([1, 2], device=device)