From 165446de6cf40b2efe1ef15745feb1d40f35854e Mon Sep 17 00:00:00 2001 From: Naoya Maruyama Date: Tue, 19 May 2020 11:35:39 -0700 Subject: [PATCH 1/2] Use int64_t and double for Int and Float, respectively. Addresses #35. --- .../csrc/jit/codegen/cuda/ir_interface_nodes.h | 17 +++++++++++------ torch/csrc/jit/codegen/cuda/ir_iostream.cpp | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/torch/csrc/jit/codegen/cuda/ir_interface_nodes.h b/torch/csrc/jit/codegen/cuda/ir_interface_nodes.h index 5998d2e123c88..1bba920d06c94 100644 --- a/torch/csrc/jit/codegen/cuda/ir_interface_nodes.h +++ b/torch/csrc/jit/codegen/cuda/ir_interface_nodes.h @@ -57,11 +57,13 @@ struct TORCH_CUDA_API Bool : public Val { * is compiled) or a constant value (inlined into the kernel definition). */ struct TORCH_CUDA_API Float : public Val { + using ScalarType = double; + ~Float() = default; Float() : Val(ValType::Scalar, DataType::Float), maybe_value_{c10::nullopt} {} - Float(float _value) + Float(ScalarType _value) : Val(ValType::Scalar, DataType::Float), maybe_value_{_value} {} Float(const Float& other) = delete; @@ -76,14 +78,14 @@ struct TORCH_CUDA_API Float : public Val { bool isConst() const { return maybe_value_.has_value(); } - c10::optional value() const noexcept { + c10::optional value() const noexcept { return maybe_value_; } bool sameAs(const Float* const other) const; private: - const c10::optional maybe_value_; + const c10::optional maybe_value_; }; /* @@ -124,11 +126,14 @@ struct TORCH_CUDA_API Half : public Val { // An Int64 value. If used for indexing it's set as size_t. Otherwise it's an // inlined literal in the kernel. struct TORCH_CUDA_API Int : public Val { + using ScalarType = int64_t; + ~Int() = default; Int() : Val(ValType::Scalar, DataType::Int), maybe_value_{c10::nullopt} {} - Int(int _value) : Val(ValType::Scalar, DataType::Int), maybe_value_{_value} {} + Int(ScalarType _value) + : Val(ValType::Scalar, DataType::Int), maybe_value_{_value} {} Int(const Int& other) = delete; Int& operator=(const Int& other) = delete; @@ -142,14 +147,14 @@ struct TORCH_CUDA_API Int : public Val { virtual bool isConst() const { return maybe_value_.has_value(); } - virtual c10::optional value() const noexcept { + virtual c10::optional value() const noexcept { return maybe_value_; } virtual bool sameAs(const Int* const other) const; private: - const c10::optional maybe_value_; + const c10::optional maybe_value_; }; struct TransformReplay; diff --git a/torch/csrc/jit/codegen/cuda/ir_iostream.cpp b/torch/csrc/jit/codegen/cuda/ir_iostream.cpp index 13645d85623e8..3beeed4a0d101 100644 --- a/torch/csrc/jit/codegen/cuda/ir_iostream.cpp +++ b/torch/csrc/jit/codegen/cuda/ir_iostream.cpp @@ -170,7 +170,8 @@ void IRPrinter::handle(const Float* const f) { os << "f" << f->name(); } else { os << "float(" - << std::setprecision(std::numeric_limits::max_digits10) + << std::setprecision( + std::numeric_limits::max_digits10) << *(f->value()) << ")"; } } From 93691f4a91ea1461ecdca6c32a6908de04458c80 Mon Sep 17 00:00:00 2001 From: jjsjann123 Date: Fri, 22 May 2020 17:34:41 -0700 Subject: [PATCH 2/2] fixing CI host --- .github/workflows/clang_format.yml | 2 +- .github/workflows/lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang_format.yml b/.github/workflows/clang_format.yml index 64f8c1fe8b745..d7e08b03983d9 100644 --- a/.github/workflows/clang_format.yml +++ b/.github/workflows/clang_format.yml @@ -29,7 +29,7 @@ jobs: set -eu # This is necessary to get the same results regardless of whether the # PR was opened directly or from a forked repo. See: `9f890a92` for more info. - git remote add upstream https://github.com/pytorch/pytorch + git remote add upstream https://github.com/csarofeen/pytorch git fetch upstream "$GITHUB_BASE_REF" BASE_SHA=${{ github.event.pull_request.base.sha }} HEAD_SHA=${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f34efcb97166c..905a6afa301a1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -121,7 +121,7 @@ jobs: - name: Run clang-tidy run: | set -eux - git remote add upstream https://github.com/pytorch/pytorch + git remote add upstream https://github.com/csarofeen/pytorch git fetch upstream "$GITHUB_BASE_REF" BASE_SHA=${{ github.event.pull_request.base.sha }} HEAD_SHA=${{ github.event.pull_request.head.sha }}