From 48f931bc21140b6de84d6d9c0914b0a3e07a1881 Mon Sep 17 00:00:00 2001 From: Siyuan Liu Date: Mon, 13 Nov 2023 21:54:42 +0000 Subject: [PATCH] fix linter --- torch_xla/csrc/elementwise.cpp | 2 +- torch_xla/csrc/helpers.cpp | 9 ++++----- torch_xla/csrc/ir.h | 8 ++++---- torch_xla/csrc/lowering_context.cpp | 3 ++- torch_xla/csrc/lowering_context.h | 5 +++-- torch_xla/csrc/reduction.cpp | 11 ++++++----- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/torch_xla/csrc/elementwise.cpp b/torch_xla/csrc/elementwise.cpp index dbc922fcd8f0..027b80a61707 100644 --- a/torch_xla/csrc/elementwise.cpp +++ b/torch_xla/csrc/elementwise.cpp @@ -16,7 +16,7 @@ namespace torch_xla { namespace { static const bool experimental_unbounded_dynamism = - runtime::sys_util::GetEnvBool("EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM", false); + runtime::sys_util::GetEnvBool("EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM", false); xla::XlaOp Between(xla::XlaOp input, const at::Scalar& min_val, const at::Scalar& max_val) { diff --git a/torch_xla/csrc/helpers.cpp b/torch_xla/csrc/helpers.cpp index 8290da239930..21f3b2857902 100644 --- a/torch_xla/csrc/helpers.cpp +++ b/torch_xla/csrc/helpers.cpp @@ -21,9 +21,8 @@ namespace torch_xla { namespace { - static const bool experimental_unbounded_dynamism = - runtime::sys_util::GetEnvBool("EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM", false); + runtime::sys_util::GetEnvBool("EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM", false); // TODO(lsy323): Get reserved number for unbounded dim after it's added in XLA. static constexpr int64_t kUnboundedSize = std::numeric_limits::min(); @@ -334,7 +333,7 @@ xla::XlaOp XlaHelpers::DynamicReshapeAs(xla::XlaOp input, bool XlaHelpers::IsUnboundedDynamic(const xla::Shape& shape) { XLA_CHECK(experimental_unbounded_dynamism) - << "EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM needs to be turned on."; + << "EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM needs to be turned on."; const absl::Span dims = shape.dimensions(); return std::any_of(dims.begin(), dims.end(), [](int64_t size) { return size == kUnboundedSize; }); @@ -344,7 +343,7 @@ xla::XlaOp XlaHelpers::DynamicUnboundedReshape( xla::XlaOp input, xla::XlaOp aux_input, absl::Span output_sizes) { XLA_CHECK(experimental_unbounded_dynamism) - << "EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM needs to be turned on."; + << "EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM needs to be turned on."; const xla::Shape& aux_input_shape = ShapeHelper::ShapeOfXlaOp(aux_input); XLA_CHECK(output_sizes.size() == aux_input_shape.rank()) << "XlaHelpers::DynamicUnboundedReshape constrainled failed!"; @@ -387,7 +386,7 @@ xla::XlaOp XlaHelpers::DynamicUnboundedBroadcast( xla::XlaOp input, xla::XlaOp aux_input, absl::Span aux_input_dimensions) { XLA_CHECK(experimental_unbounded_dynamism) - << "EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM needs to be turned on."; + << "EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM needs to be turned on."; const xla::Shape& input_shape = ShapeHelper::ShapeOfXlaOp(input); const xla::Shape& aux_input_shape = ShapeHelper::ShapeOfXlaOp(aux_input); bool all_static = true; diff --git a/torch_xla/csrc/ir.h b/torch_xla/csrc/ir.h index e4c48a01b123..8c852573730c 100644 --- a/torch_xla/csrc/ir.h +++ b/torch_xla/csrc/ir.h @@ -138,11 +138,11 @@ class XlaNode : public torch::lazy::Node { std::string ToString() const override; - void MarkDynamicDimension(uint32_t dim) { - dynamic_dims_.insert(dim); - } + void MarkDynamicDimension(uint32_t dim) { dynamic_dims_.insert(dim); } - const std::unordered_set& dynamic_dims() const { return dynamic_dims_; } + const std::unordered_set& dynamic_dims() const { + return dynamic_dims_; + } protected: std::unordered_set dynamic_dims_; diff --git a/torch_xla/csrc/lowering_context.cpp b/torch_xla/csrc/lowering_context.cpp index 07fda8c425b0..404fa82ea7b1 100644 --- a/torch_xla/csrc/lowering_context.cpp +++ b/torch_xla/csrc/lowering_context.cpp @@ -116,7 +116,8 @@ xla::XlaOp LoweringContext::GetParameter( parameters_.push_back(data); } else { XLA_CHECK(unbounded_dynamic_dims.empty()) - << "The unbounded dynamic dims can only be set when Parameter is created."; + << "The unbounded dynamic dims can only be set when Parameter is " + "created."; } parameter_sequence_.push_back(it->second.index); return it->second.param; diff --git a/torch_xla/csrc/lowering_context.h b/torch_xla/csrc/lowering_context.h index c09fb4cd9fb3..b46d91874b02 100644 --- a/torch_xla/csrc/lowering_context.h +++ b/torch_xla/csrc/lowering_context.h @@ -36,8 +36,9 @@ class LoweringContext : public torch::lazy::LoweringContext { // If a parameter associated with data has already been declared, it will be // returned. Otherwise a new one will be created, associated with the tensor // held in data. - xla::XlaOp GetParameter(const std::shared_ptr& data, - const std::unordered_set& dynamic_dims = {}); + xla::XlaOp GetParameter( + const std::shared_ptr& data, + const std::unordered_set& dynamic_dims = {}); // Retrieves the vector holding all the tensors associated with the parameter // instructions which have been created. diff --git a/torch_xla/csrc/reduction.cpp b/torch_xla/csrc/reduction.cpp index d5f243cf5dad..336123a542e3 100644 --- a/torch_xla/csrc/reduction.cpp +++ b/torch_xla/csrc/reduction.cpp @@ -32,7 +32,7 @@ struct SummationResult { }; static const bool experimental_unbounded_dynamism = - runtime::sys_util::GetEnvBool("EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM", false); + runtime::sys_util::GetEnvBool("EXPERIMENTAL_XLA_UNBOUNDED_DYNAMISM", false); ReductionInfo GetReductionInfo(xla::XlaOp input, const xla::Shape& shape, absl::Span dimensions, @@ -121,12 +121,13 @@ SummationResult CreateSummation(xla::XlaOp input, } if (keep_reduced_dimensions) { if (experimental_unbounded_dynamism) { - // TODO(lsy323): Use XLA DynamicReshape once unbounded dynamism support is added. + // TODO(lsy323): Use XLA DynamicReshape once unbounded dynamism support is + // added. result.result = XlaHelpers::DynamicUnboundedReshape( - result.result, input, result.rinfo.new_dimensions); + result.result, input, result.rinfo.new_dimensions); } else { - result.result = - XlaHelpers::DynamicReshape(result.result, result.rinfo.new_dimensions); + result.result = XlaHelpers::DynamicReshape(result.result, + result.rinfo.new_dimensions); } } return result;