Skip to content

Commit fddabc6

Browse files
r-barnespytorchmergebot
authored andcommitted
C10_UNUSED to [[maybe_unused]] (pytorch#6357) (pytorch#138364)
Summary: Pull Request resolved: pytorch/executorch#6357 Pull Request resolved: pytorch#138364 Approved by: https://github.com/Skylion007, https://github.com/eqy
1 parent 2f6a70b commit fddabc6

File tree

139 files changed

+841
-697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+841
-697
lines changed

aten/src/ATen/CPUApplyUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct strided_tensor_iter_fixed {
6868
strided_tensor_iter_fixed(strided_tensor_iter_fixed&&) = default;
6969
strided_tensor_iter_fixed(
7070
Tensor& tensor,
71-
C10_UNUSED bool sort_strides = false)
71+
[[maybe_unused]] bool sort_strides = false)
7272
: data_(tensor.data_ptr<T>()) {
7373
std::memset(counter_, 0, sizeof(int64_t) * N);
7474
if (tensor.dim() > 0) {

aten/src/ATen/Dispatch.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,38 +63,38 @@ TORCH_API void record_kernel_function_dtype(std::string name);
6363
} \
6464
} while (0)
6565

66-
#define AT_PRIVATE_CASE_TYPE_USING_HINT(enum_type, HINT, ...) \
67-
case enum_type: { \
68-
AT_PRIVATE_CHECK_SELECTIVE_BUILD(enum_type); \
69-
using HINT C10_UNUSED = c10::impl::ScalarTypeToCPPTypeT<enum_type>; \
70-
return __VA_ARGS__(); \
66+
#define AT_PRIVATE_CASE_TYPE_USING_HINT(enum_type, HINT, ...) \
67+
case enum_type: { \
68+
AT_PRIVATE_CHECK_SELECTIVE_BUILD(enum_type); \
69+
using HINT [[maybe_unused]] = c10::impl::ScalarTypeToCPPTypeT<enum_type>; \
70+
return __VA_ARGS__(); \
7171
}
7272

7373
#define AT_DISPATCH_CASE(enum_type, ...) \
7474
AT_PRIVATE_CASE_TYPE_USING_HINT(enum_type, scalar_t, __VA_ARGS__)
7575

76-
#define AT_DISPATCH_CASE_QINT(enum_type, scalar_type, ...) \
77-
case enum_type: { \
78-
AT_PRIVATE_CHECK_SELECTIVE_BUILD(enum_type); \
79-
using scalar_t = scalar_type; \
80-
using underlying_t C10_UNUSED = typename scalar_t::underlying; \
81-
C10_UNUSED const auto& SCALAR_TYPE = enum_type; \
82-
C10_UNUSED const auto& UNDERLYING_TYPE = toUnderlying(enum_type); \
83-
return __VA_ARGS__(); \
76+
#define AT_DISPATCH_CASE_QINT(enum_type, scalar_type, ...) \
77+
case enum_type: { \
78+
AT_PRIVATE_CHECK_SELECTIVE_BUILD(enum_type); \
79+
using scalar_t = scalar_type; \
80+
using underlying_t [[maybe_unused]] = typename scalar_t::underlying; \
81+
[[maybe_unused]] const auto& SCALAR_TYPE = enum_type; \
82+
[[maybe_unused]] const auto& UNDERLYING_TYPE = toUnderlying(enum_type); \
83+
return __VA_ARGS__(); \
8484
}
8585

86-
#define AT_QINT_SUB_BYTE_PRIVATE_CASE_TYPE( \
87-
enum_type, scalar_type, bitwidth, qmin, qmax, ...) \
88-
case enum_type: { \
89-
AT_PRIVATE_CHECK_SELECTIVE_BUILD(enum_type); \
90-
using scalar_t = scalar_type; \
91-
using underlying_t C10_UNUSED = typename scalar_t::underlying; \
92-
C10_UNUSED const auto& SCALAR_TYPE = enum_type; \
93-
C10_UNUSED const auto& UNDERLYING_TYPE = toUnderlying(enum_type); \
94-
C10_UNUSED int bit_width = bitwidth; \
95-
C10_UNUSED int64_t quant_min = qmin; \
96-
C10_UNUSED int64_t quant_max = qmax; \
97-
return __VA_ARGS__(); \
86+
#define AT_QINT_SUB_BYTE_PRIVATE_CASE_TYPE( \
87+
enum_type, scalar_type, bitwidth, qmin, qmax, ...) \
88+
case enum_type: { \
89+
AT_PRIVATE_CHECK_SELECTIVE_BUILD(enum_type); \
90+
using scalar_t = scalar_type; \
91+
using underlying_t [[maybe_unused]] = typename scalar_t::underlying; \
92+
[[maybe_unused]] const auto& SCALAR_TYPE = enum_type; \
93+
[[maybe_unused]] const auto& UNDERLYING_TYPE = toUnderlying(enum_type); \
94+
[[maybe_unused]] int bit_width = bitwidth; \
95+
[[maybe_unused]] int64_t quant_min = qmin; \
96+
[[maybe_unused]] int64_t quant_max = qmax; \
97+
return __VA_ARGS__(); \
9898
}
9999

100100
namespace detail {

aten/src/ATen/FunctionalTensorWrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ void replace_(const ITensorListRef functional_tensor, ITensorListRef other) {
638638
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(functional_tensor.size() == other.size());
639639
auto functional_tensor_it = functional_tensor.begin();
640640
auto other_it = other.begin();
641-
for (C10_UNUSED const auto i : c10::irange(functional_tensor.size())) {
641+
for ([[maybe_unused]] const auto i : c10::irange(functional_tensor.size())) {
642642
replace_(*functional_tensor_it++, *other_it++);
643643
}
644644
}
@@ -655,7 +655,7 @@ void propagate_xla_data(const ITensorListRef functional_tensor, ITensorListRef o
655655
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(functional_tensor.size() == other.size());
656656
auto functional_tensor_it = functional_tensor.begin();
657657
auto other_it = other.begin();
658-
for (C10_UNUSED const auto i : c10::irange(functional_tensor.size())) {
658+
for ([[maybe_unused]] const auto i : c10::irange(functional_tensor.size())) {
659659
propagate_xla_data(*functional_tensor_it++, *other_it++);
660660
}
661661
}
@@ -670,7 +670,7 @@ void propagate_xla_data_direct(const ITensorListRef tensor,
670670
ITensorListRef other) {
671671
auto tensor_it = tensor.begin();
672672
auto other_it = other.begin();
673-
for (C10_UNUSED const auto i : c10::irange(tensor.size())) {
673+
for ([[maybe_unused]] const auto i : c10::irange(tensor.size())) {
674674
propagate_xla_data_direct(*tensor_it++, *other_it++);
675675
}
676676
}

aten/src/ATen/code_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ struct CodeTemplate {
205205
// or trailing newlines. It's the responsibility of the calling function
206206
// to indent correctly in the context.
207207
void emitIndent(std::ostream& out, size_t indent) const {
208-
for (C10_UNUSED const auto i : c10::irange(indent)) {
208+
for ([[maybe_unused]] const auto i : c10::irange(indent)) {
209209
out << " ";
210210
}
211211
}

aten/src/ATen/core/Formatting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static std::tuple<double, int> __printFormat(std::ostream& stream, const Tensor&
153153

154154
static void __printIndent(std::ostream &stream, int64_t indent)
155155
{
156-
for (C10_UNUSED const auto i : c10::irange(indent)) {
156+
for ([[maybe_unused]] const auto i : c10::irange(indent)) {
157157
stream << " ";
158158
}
159159
}

aten/src/ATen/core/class_type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ struct TORCH_API ClassType : public NamedType {
390390
std::string doc_string = "",
391391
std::vector<std::string> unresolved_class_attributes = {});
392392

393-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
393+
std::string annotation_str_impl(
394+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
394395
const auto& n = name().value();
395396
return n.qualifiedName();
396397
}

aten/src/ATen/core/dynamic_type.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ DynamicTypePtr ivalue::TupleTypeFactory<c10::DynamicType>::fallback(
376376
return nullptr;
377377
}
378378

379-
TORCH_API TupleTypePtr
380-
ivalue::TupleTypeFactory<TupleType>::fallback(C10_UNUSED const Type& type) {
379+
TORCH_API TupleTypePtr ivalue::TupleTypeFactory<TupleType>::fallback(
380+
[[maybe_unused]] const Type& type) {
381381
#ifdef C10_MOBILE
382382
return nullptr;
383383
#else
@@ -398,5 +398,4 @@ ivalue::TupleTypeFactory<TupleType>::fallback(C10_UNUSED const Type& type) {
398398
#endif
399399
}
400400

401-
402401
} // namespace c10

aten/src/ATen/core/enum_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct TORCH_API EnumType : public NamedType {
8888
cu_(std::move(cu)) {}
8989

9090
std::string annotation_str_impl(
91-
C10_UNUSED const TypePrinter& printer = nullptr) const override {
91+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
9292
const auto& n = name().value();
9393
return n.qualifiedName();
9494
}

aten/src/ATen/core/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct TORCH_API Function {
5656
virtual c10::intrusive_ptr<c10::ivalue::Future> runAsync(
5757
Stack& /*stack*/,
5858
// NOLINTNEXTLINE(performance-unnecessary-value-param)
59-
C10_UNUSED TaskLauncher taskLauncher = at::launch) {
59+
[[maybe_unused]] TaskLauncher taskLauncher = at::launch) {
6060
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(false);
6161
return {};
6262
}

aten/src/ATen/core/jit_type.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,8 @@ struct TORCH_API NumberType : public Type {
12781278
protected:
12791279
NumberType(TypeKind kind = TypeKind::NumberType) : Type(kind) {}
12801280

1281-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
1281+
std::string annotation_str_impl(
1282+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
12821283
return "number"; // technically not a valid python type, but
12831284
// we need to use it when parsing back in annotations
12841285
// for implicit conversions
@@ -1305,7 +1306,8 @@ struct TORCH_API FloatType : public NumberType {
13051306

13061307
private:
13071308
FloatType() : NumberType(TypeKind::FloatType) {}
1308-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
1309+
std::string annotation_str_impl(
1310+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
13091311
return "float";
13101312
}
13111313
};
@@ -1330,7 +1332,8 @@ struct TORCH_API ComplexType : public NumberType {
13301332

13311333
private:
13321334
ComplexType() : NumberType(TypeKind::ComplexType) {}
1333-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
1335+
std::string annotation_str_impl(
1336+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
13341337
return "complex";
13351338
}
13361339
};
@@ -1419,7 +1422,8 @@ struct TORCH_API IntType : public NumberType {
14191422

14201423
private:
14211424
IntType() : NumberType(TypeKind::IntType) {}
1422-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
1425+
std::string annotation_str_impl(
1426+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
14231427
return "int";
14241428
}
14251429
};
@@ -1453,7 +1457,8 @@ struct TORCH_API StringType : public Type {
14531457
// we only use "str" (not "string") in both FunctionSchema and script
14541458
return annotation_str();
14551459
}
1456-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
1460+
std::string annotation_str_impl(
1461+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
14571462
return "str";
14581463
}
14591464
static const TypeKind Kind = TypeKind::StringType;
@@ -1473,7 +1478,8 @@ struct TORCH_API StorageType : public Type {
14731478
std::string str() const override {
14741479
return annotation_str();
14751480
}
1476-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
1481+
std::string annotation_str_impl(
1482+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
14771483
return "Storage";
14781484
}
14791485
static const TypeKind Kind = TypeKind::StorageType;
@@ -1508,7 +1514,8 @@ struct TORCH_API FunctionType : public NamedType {
15081514

15091515
private:
15101516
FunctionType(torch::jit::Function* function);
1511-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
1517+
std::string annotation_str_impl(
1518+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
15121519
const auto& n = name().value();
15131520
return n.qualifiedName();
15141521
}
@@ -2199,7 +2206,8 @@ struct TORCH_API InterfaceType : public NamedType {
21992206
const InterfaceType& rhs,
22002207
std::ostream* why_not);
22012208

2202-
std::string annotation_str_impl(C10_UNUSED const TypePrinter& printer = nullptr) const override {
2209+
std::string annotation_str_impl(
2210+
[[maybe_unused]] const TypePrinter& printer = nullptr) const override {
22032211
return name()->qualifiedName();
22042212
}
22052213

0 commit comments

Comments
 (0)