diff --git a/.lintrunner.toml b/.lintrunner.toml index 5fa37ef3b6b01..4789991736be1 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -210,8 +210,6 @@ include_patterns = [ 'aten/src/ATen/native/nested/*.h', 'c10/**/*.cpp', 'c10/**/*.h', - 'caffe2/**/*.cc', - 'caffe2/**/*.h', 'torch/*.h', 'torch/csrc/*.h', 'torch/csrc/*.cpp', diff --git a/BUCK.oss b/BUCK.oss index 448cce08cd854..13d5518801a24 100644 --- a/BUCK.oss +++ b/BUCK.oss @@ -65,6 +65,7 @@ cxx_library( "caffe2/serialize/file_adapter.cc", "caffe2/serialize/inline_container.cc", "caffe2/serialize/istream_adapter.cc", + "caffe2/serialize/read_adapter_interface.cc", ], visibility = ["PUBLIC"], deps = [ diff --git a/BUILD.bazel b/BUILD.bazel index e5ab0d0e29b85..1018f7907adec 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -473,6 +473,7 @@ filegroup( "caffe2/serialize/file_adapter.cc", "caffe2/serialize/inline_container.cc", "caffe2/serialize/istream_adapter.cc", + "caffe2/serialize/read_adapter_interface.cc", ], ) diff --git a/build.bzl b/build.bzl index 3b72864f047ae..dbb1866ac5482 100644 --- a/build.bzl +++ b/build.bzl @@ -34,6 +34,7 @@ def define_targets(rules): "caffe2/serialize/file_adapter.cc", "caffe2/serialize/inline_container.cc", "caffe2/serialize/istream_adapter.cc", + "caffe2/serialize/read_adapter_interface.cc", ], copts = ["-fexceptions"], tags = [ diff --git a/caffe2/core/timer.h b/caffe2/core/timer.h index 28d373f468d0d..a0384b0dbdbd0 100644 --- a/caffe2/core/timer.h +++ b/caffe2/core/timer.h @@ -3,7 +3,7 @@ #include -#include +#include "caffe2/core/common.h" namespace caffe2 { diff --git a/caffe2/perfkernels/common_avx.cc b/caffe2/perfkernels/common_avx.cc index cdb8b760a0d9e..08c70d8966bc0 100644 --- a/caffe2/perfkernels/common_avx.cc +++ b/caffe2/perfkernels/common_avx.cc @@ -2,7 +2,7 @@ // example, if your compiler did not specify -mavx, you should not provide // the CAFFE2_PERF_WITH_AVX macro. -#include "caffe2/core/macros.h" +#include "caffe2/core/common.h" #ifdef CAFFE2_PERF_WITH_AVX #ifndef __AVX__ diff --git a/caffe2/perfkernels/common_avx2.cc b/caffe2/perfkernels/common_avx2.cc index a45d887b2b49a..3db34aa549d88 100644 --- a/caffe2/perfkernels/common_avx2.cc +++ b/caffe2/perfkernels/common_avx2.cc @@ -2,7 +2,7 @@ // example, if your compiler did not specify -mavx2, you should not provide // the CAFFE2_PERF_WITH_AVX2 macro. -#include "caffe2/core/macros.h" +#include "caffe2/core/common.h" #ifdef CAFFE2_PERF_WITH_AVX2 #ifndef __AVX2__ diff --git a/caffe2/serialize/CMakeLists.txt b/caffe2/serialize/CMakeLists.txt index 30303e8b744cb..1552b59d0d441 100644 --- a/caffe2/serialize/CMakeLists.txt +++ b/caffe2/serialize/CMakeLists.txt @@ -6,7 +6,8 @@ list(APPEND Caffe2_CPU_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/inline_container.cc ${CMAKE_CURRENT_SOURCE_DIR}/istream_adapter.cc ${CMAKE_CURRENT_SOURCE_DIR}/file_adapter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/crc.cc) + ${CMAKE_CURRENT_SOURCE_DIR}/crc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/read_adapter_interface.cc) list(APPEND Caffe2_CPU_INCLUDE ${PROJECT_SOURCE_DIR}/third_party/miniz-2.1.0) set(Caffe2_CPU_TEST_SRCS ${Caffe2_CPU_TEST_SRCS} PARENT_SCOPE) diff --git a/caffe2/serialize/crc_alt.h b/caffe2/serialize/crc_alt.h index 10f9c6bdb380e..9d1c4f1dc7ddc 100644 --- a/caffe2/serialize/crc_alt.h +++ b/caffe2/serialize/crc_alt.h @@ -25,7 +25,7 @@ // using the aforementioned #defines the table is automatically fitted to your needs // uint8_t, uint32_t, int32_t -#include +#include // size_t #include diff --git a/caffe2/serialize/file_adapter.cc b/caffe2/serialize/file_adapter.cc index f112dd61e5dbf..67634d7f7fd27 100644 --- a/caffe2/serialize/file_adapter.cc +++ b/caffe2/serialize/file_adapter.cc @@ -3,11 +3,13 @@ #include #include #include +#include "caffe2/core/common.h" -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { -FileAdapter::RAIIFile::RAIIFile(const std::string& file_name) - : fp_(fopen(file_name.c_str(), "rb")) { +FileAdapter::RAIIFile::RAIIFile(const std::string& file_name) { + fp_ = fopen(file_name.c_str(), "rb"); if (fp_ == nullptr) { auto old_errno = errno; #if defined(_WIN32) && (defined(__MINGW32__) || defined(_MSC_VER)) @@ -75,4 +77,5 @@ size_t FileAdapter::read(uint64_t pos, void* buf, size_t n, const char* what) FileAdapter::~FileAdapter() = default; -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/file_adapter.h b/caffe2/serialize/file_adapter.h index 36663e3ea8dee..36bc5de271003 100644 --- a/caffe2/serialize/file_adapter.h +++ b/caffe2/serialize/file_adapter.h @@ -1,11 +1,14 @@ #pragma once +#include +#include #include -#include +#include "caffe2/serialize/istream_adapter.h" #include "caffe2/serialize/read_adapter_interface.h" -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { class TORCH_API FileAdapter final : public ReadAdapterInterface { public: @@ -29,4 +32,5 @@ class TORCH_API FileAdapter final : public ReadAdapterInterface { uint64_t size_; }; -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/in_memory_adapter.h b/caffe2/serialize/in_memory_adapter.h index 869ead3b24563..817f3f5d67749 100644 --- a/caffe2/serialize/in_memory_adapter.h +++ b/caffe2/serialize/in_memory_adapter.h @@ -1,9 +1,10 @@ #pragma once -#include -#include #include +#include -namespace caffe2::serialize { + +namespace caffe2 { +namespace serialize { class MemoryReadAdapter final : public caffe2::serialize::ReadAdapterInterface { public: @@ -14,18 +15,18 @@ class MemoryReadAdapter final : public caffe2::serialize::ReadAdapterInterface { return size_; } - size_t read( - uint64_t pos, - void* buf, - size_t n, - const char* what [[maybe_unused]] = "") const override { + size_t read(uint64_t pos, void* buf, size_t n, const char* what = "") + const override { + (void) what; memcpy(buf, (int8_t*)(data_) + pos, n); return n; } private: const void* data_; - off_t size_{}; + off_t size_; }; -} // namespace caffe2::serialize + +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/inline_container.cc b/caffe2/serialize/inline_container.cc index c232838dec0c4..2761147cf333d 100644 --- a/caffe2/serialize/inline_container.cc +++ b/caffe2/serialize/inline_container.cc @@ -10,11 +10,15 @@ #include #include +#include +#include #include +#include #include #include #include +#include "caffe2/core/common.h" #include "caffe2/serialize/file_adapter.h" #include "caffe2/serialize/inline_container.h" #include "caffe2/serialize/istream_adapter.h" @@ -23,8 +27,8 @@ #include "caffe2/serialize/versions.h" #include "miniz.h" - -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { constexpr c10::string_view kDebugPklSuffix(".debug_pkl"); struct MzZipReaderIterWrapper { @@ -190,7 +194,8 @@ void PyTorchStreamReader::init() { // version check at::DataPtr version_ptr; - size_t version_size = 0; + // NOLINTNEXTLINE(cppcoreguidelines-init-variables) + size_t version_size; if (hasRecord(".data/version")) { std::tie(version_ptr, version_size) = getRecord(".data/version"); } else { @@ -199,7 +204,7 @@ void PyTorchStreamReader::init() { } std::string version(static_cast(version_ptr.get()), version_size); try { - version_ = std::stoll(version); + version_ = std::stoull(version); } catch (const std::invalid_argument& e) { CAFFE_THROW("Couldn't parse the version ", version, @@ -622,7 +627,7 @@ PyTorchStreamWriter::PyTorchStreamWriter(const std::string& file_name) } PyTorchStreamWriter::PyTorchStreamWriter( - const std::function& writer_func) + const std::function writer_func) : archive_name_("archive"), writer_func_(writer_func) { setup(archive_name_); @@ -633,7 +638,7 @@ void PyTorchStreamWriter::setup(const string& file_name) { memset(ar_.get(), 0, sizeof(mz_zip_archive)); archive_name_plus_slash_ = archive_name_ + "/"; // for writeRecord(). - if (archive_name_.empty()) { + if (archive_name_.size() == 0) { CAFFE_THROW("invalid file name: ", file_name); } if (!writer_func_) { @@ -644,7 +649,7 @@ void PyTorchStreamWriter::setup(const string& file_name) { const std::string dir_name = parentdir(file_name); if(!dir_name.empty()) { - struct stat st{}; + struct stat st; bool dir_exists = (stat(dir_name.c_str(), &st) == 0 && (st.st_mode & S_IFDIR)); TORCH_CHECK(dir_exists, "Parent directory ", dir_name, " does not exist."); } @@ -701,8 +706,8 @@ void PyTorchStreamWriter::writeRecord( /*uncomp_size=*/0, /*uncomp_crc32=*/0, /*last_modified=*/nullptr, - /*user_extra_data_local=*/padding_.c_str(), - /*user_extra_data_local_len=*/padding_size, + /*user_extra_data=*/padding_.c_str(), + /*user_extra_data_len=*/padding_size, /*user_extra_data_central=*/nullptr, /*user_extra_data_central_len=*/0); valid("writing file ", name.c_str()); @@ -815,4 +820,5 @@ PyTorchStreamWriter::~PyTorchStreamWriter() { } } -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/inline_container.h b/caffe2/serialize/inline_container.h index fe319e9011bc3..6a13d414feb9e 100644 --- a/caffe2/serialize/inline_container.h +++ b/caffe2/serialize/inline_container.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -90,8 +91,8 @@ typedef struct mz_zip_archive mz_zip_archive; // model.json as the last file when writing after we have accumulated all // other information. - -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { static constexpr const char* kSerializationIdRecordName = ".data/serialization_id"; @@ -195,18 +196,18 @@ class TORCH_API PyTorchStreamReader final { std::string archive_name_; std::string archive_name_plus_slash_; std::shared_ptr in_; - int64_t version_{}; + int64_t version_; std::mutex reader_lock_; bool load_debug_symbol_ = true; std::string serialization_id_; - size_t additional_reader_size_threshold_{}; + size_t additional_reader_size_threshold_; }; class TORCH_API PyTorchStreamWriter final { public: explicit PyTorchStreamWriter(const std::string& archive_name); explicit PyTorchStreamWriter( - const std::function& writer_func); + const std::function writer_func); void setMinVersion(const uint64_t version); @@ -273,4 +274,5 @@ size_t getPadding( std::string& padding_buf); } // namespace detail -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/inline_container_test.cc b/caffe2/serialize/inline_container_test.cc index 4e58c0d609932..4e027f681961d 100644 --- a/caffe2/serialize/inline_container_test.cc +++ b/caffe2/serialize/inline_container_test.cc @@ -5,14 +5,12 @@ #include -#include -#include #include "caffe2/serialize/inline_container.h" -#include "caffe2/serialize/istream_adapter.h" - +#include +#include "c10/util/irange.h" -// NOLINTBEGIN(*-narrowing-conversions) -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { namespace { TEST(PyTorchStreamWriterAndReader, SaveAndLoad) { @@ -21,7 +19,7 @@ TEST(PyTorchStreamWriterAndReader, SaveAndLoad) { std::ostringstream oss; // write records through writers PyTorchStreamWriter writer([&](const void* b, size_t n) -> size_t { - oss.write(static_cast(b), static_cast(n)); + oss.write(static_cast(b), n); return oss ? n : 0; }); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,cppcoreguidelines-avoid-magic-numbers) @@ -30,14 +28,14 @@ TEST(PyTorchStreamWriterAndReader, SaveAndLoad) { std::vector buf(data1.size()); for (auto i : c10::irange(data1.size())) { - data1[i] = static_cast(data1.size() - i); + data1[i] = data1.size() - i; } writer.writeRecord("key1", data1.data(), data1.size()); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,cppcoreguidelines-avoid-magic-numbers) std::array data2; for (auto i : c10::irange(data2.size())) { - data2[i] = static_cast(data2.size() - i); + data2[i] = data2.size() - i; } writer.writeRecord("key2", data2.data(), data2.size()); @@ -151,7 +149,7 @@ TEST(PyTorchStreamWriterAndReader, LoadWithMultiThreads) { PyTorchStreamReader reader(&iss); reader.setAdditionalReaderSizeThreshold(0); // before testing, sanity check - int64_t size1 = 0, size2 = 0, ret = 0; + int64_t size1, size2, ret; at::DataPtr data_ptr; std::tie(data_ptr, size1) = reader.getRecord("key1"); std::tie(data_ptr, size2) = reader.getRecord("key2"); @@ -298,7 +296,7 @@ TEST(PytorchStreamWriterAndReader, SkipDebugRecords) { reader.setShouldLoadDebugSymbol(false); EXPECT_FALSE(reader.hasRecord("key1.debug_pkl")); at::DataPtr ptr; - size_t size = 0; + size_t size; std::tie(ptr, size) = reader.getRecord("key1.debug_pkl"); EXPECT_EQ(size, 0); std::vector dst(data1.size()); @@ -481,5 +479,5 @@ TEST_P(ChunkRecordIteratorTest, ChunkRead) { } } // namespace -} // namespace caffe2::serialize -// NOLINTEND(*-narrowing-conversions) +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/istream_adapter.cc b/caffe2/serialize/istream_adapter.cc index baad0e9b2ee69..9509a088736ef 100644 --- a/caffe2/serialize/istream_adapter.cc +++ b/caffe2/serialize/istream_adapter.cc @@ -1,7 +1,8 @@ #include "caffe2/serialize/istream_adapter.h" #include -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { IStreamAdapter::IStreamAdapter(std::istream* istream) : istream_(istream) {} @@ -32,6 +33,8 @@ void IStreamAdapter::validate(const char* what) const { } } -IStreamAdapter::~IStreamAdapter() = default; +// NOLINTNEXTLINE(modernize-use-equals-default) +IStreamAdapter::~IStreamAdapter() {} -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/istream_adapter.h b/caffe2/serialize/istream_adapter.h index 69f91faf3a79f..680c288a15f2e 100644 --- a/caffe2/serialize/istream_adapter.h +++ b/caffe2/serialize/istream_adapter.h @@ -5,7 +5,8 @@ #include "c10/macros/Macros.h" #include "caffe2/serialize/read_adapter_interface.h" -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { // this is a reader implemented by std::istream class TORCH_API IStreamAdapter final : public ReadAdapterInterface { @@ -22,4 +23,5 @@ class TORCH_API IStreamAdapter final : public ReadAdapterInterface { void validate(const char* what) const; }; -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/read_adapter_interface.cc b/caffe2/serialize/read_adapter_interface.cc new file mode 100644 index 0000000000000..e9b84660efd72 --- /dev/null +++ b/caffe2/serialize/read_adapter_interface.cc @@ -0,0 +1,10 @@ +#include "caffe2/serialize/read_adapter_interface.h" + +namespace caffe2 { +namespace serialize { + +// NOLINTNEXTLINE(modernize-use-equals-default) +ReadAdapterInterface::~ReadAdapterInterface() {} + +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/read_adapter_interface.h b/caffe2/serialize/read_adapter_interface.h index 450db5c9b739c..0a6b5b74a762e 100644 --- a/caffe2/serialize/read_adapter_interface.h +++ b/caffe2/serialize/read_adapter_interface.h @@ -3,19 +3,21 @@ #include #include -#include +#include "c10/macros/Macros.h" -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { // this is the interface for the (file/stream/memory) reader in -// PyTorchStreamReader. With this interface, we can extend the support +// PyTorchStreamReader. with this interface, we can extend the support // besides standard istream class TORCH_API ReadAdapterInterface { public: virtual size_t size() const = 0; virtual size_t read(uint64_t pos, void* buf, size_t n, const char* what = "") const = 0; - virtual ~ReadAdapterInterface() = default; + virtual ~ReadAdapterInterface(); }; -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/serialize/versions.h b/caffe2/serialize/versions.h index aa3a6b1753aa6..6e2c27adc8fae 100644 --- a/caffe2/serialize/versions.h +++ b/caffe2/serialize/versions.h @@ -1,7 +1,8 @@ #pragma once #include -namespace caffe2::serialize { +namespace caffe2 { +namespace serialize { constexpr uint64_t kMinSupportedFileFormatVersion = 0x1L; @@ -128,4 +129,5 @@ constexpr uint64_t kProducedBytecodeVersion = 0x8L; constexpr uint64_t kMinSupportedBytecodeVersion = 0x4L; constexpr uint64_t kMaxSupportedBytecodeVersion = 0x9L; -} // namespace caffe2::serialize +} // namespace serialize +} // namespace caffe2 diff --git a/caffe2/utils/string_utils.cc b/caffe2/utils/string_utils.cc index 8e31ada6e12ec..ba763738f7bb0 100644 --- a/caffe2/utils/string_utils.cc +++ b/caffe2/utils/string_utils.cc @@ -51,7 +51,7 @@ size_t editDistance( (c)=(uint8_t)(s)[(i)++]; \ } -size_t editDistanceHelper(const char* s1, +int32_t editDistanceHelper(const char* s1, size_t s1_len, const char* s2, size_t s2_len, diff --git a/caffe2/utils/string_utils.h b/caffe2/utils/string_utils.h index 677e25deed76e..6bf3b867b5434 100644 --- a/caffe2/utils/string_utils.h +++ b/caffe2/utils/string_utils.h @@ -39,7 +39,7 @@ TORCH_API inline bool EndsWith( } } -TORCH_API size_t editDistanceHelper( +TORCH_API int32_t editDistanceHelper( const char* s1, size_t s1_len, const char* s2, diff --git a/caffe2/utils/threadpool/ThreadPool.h b/caffe2/utils/threadpool/ThreadPool.h index b5bc9dd44fdda..dbaefc51389ff 100644 --- a/caffe2/utils/threadpool/ThreadPool.h +++ b/caffe2/utils/threadpool/ThreadPool.h @@ -1,11 +1,15 @@ #ifndef CAFFE2_UTILS_THREADPOOL_H_ #define CAFFE2_UTILS_THREADPOOL_H_ +#include "ThreadPoolCommon.h" + +#include #include #include #include +#include -#include +#include "caffe2/core/common.h" // // A work-stealing threadpool loosely based off of pthreadpool diff --git a/caffe2/utils/threadpool/pthreadpool.cc b/caffe2/utils/threadpool/pthreadpool.cc index 2f2866a77d4a9..b8c6c7cebb8e8 100644 --- a/caffe2/utils/threadpool/pthreadpool.cc +++ b/caffe2/utils/threadpool/pthreadpool.cc @@ -1,9 +1,9 @@ /* Standard C headers */ -#include - -#include -#include -#include +#include +#include +#include +#include +#include #include #ifdef _MSC_VER @@ -71,8 +71,8 @@ void legacy_pthreadpool_compute_1d_tiled( } struct compute_2d_context { - legacy_pthreadpool_function_2d_t function{}; - void* argument{}; + legacy_pthreadpool_function_2d_t function; + void* argument; caffe2::FixedDivisor range_j; }; @@ -80,8 +80,8 @@ static void compute_2d(void* context_, size_t linear_index) { TORCH_DCHECK_LE(linear_index, std::numeric_limits::max()); const struct compute_2d_context* context = static_cast(context_); - int32_t q = 0; - int32_t r = 0; + int32_t q; + int32_t r; context->range_j.DivMod(static_cast(linear_index), &q, &r); context->function(context->argument, q, r); } @@ -112,18 +112,18 @@ void legacy_pthreadpool_compute_2d( } struct compute_2d_tiled_context { - legacy_pthreadpool_function_2d_tiled_t function{}; - void* argument{}; + legacy_pthreadpool_function_2d_tiled_t function; + void* argument; caffe2::FixedDivisor tile_range_j; - size_t range_i{}; - size_t range_j{}; - size_t tile_i{}; - size_t tile_j{}; + size_t range_i; + size_t range_j; + size_t tile_i; + size_t tile_j; }; static void compute_2d_tiled(void* context_, size_t linear_index) { - int32_t q = 0; - int32_t r = 0; + int32_t q; + int32_t r; const struct compute_2d_tiled_context* context = static_cast(context_); context->tile_range_j.DivMod(linear_index, &q, &r); @@ -172,26 +172,26 @@ void legacy_pthreadpool_compute_2d_tiled( } struct compute_3d_tiled_context { - legacy_pthreadpool_function_3d_tiled_t function{}; - void* argument{}; + legacy_pthreadpool_function_3d_tiled_t function; + void* argument; caffe2::FixedDivisor tile_range_j; caffe2::FixedDivisor tile_range_k; - size_t range_i{}; - size_t range_j{}; - size_t range_k{}; - size_t tile_i{}; - size_t tile_j{}; - size_t tile_k{}; + size_t range_i; + size_t range_j; + size_t range_k; + size_t tile_i; + size_t tile_j; + size_t tile_k; }; static void compute_3d_tiled( void* context_, size_t linear_index) { - int32_t tile_index_ij = 0, tile_index_k = 0; + int32_t tile_index_ij, tile_index_k; const struct compute_3d_tiled_context* context = static_cast(context_); context->tile_range_k.DivMod( static_cast(linear_index), &tile_index_ij, &tile_index_k); - int32_t tile_index_i = 0, tile_index_j = 0; + int32_t tile_index_i, tile_index_j; context->tile_range_j.DivMod(tile_index_ij, &tile_index_i, &tile_index_j); const size_t max_tile_i = context->tile_i; const size_t max_tile_j = context->tile_j; @@ -261,31 +261,31 @@ void legacy_pthreadpool_compute_3d_tiled( } struct compute_4d_tiled_context { - legacy_pthreadpool_function_4d_tiled_t function{}; - void* argument{}; + legacy_pthreadpool_function_4d_tiled_t function; + void* argument; caffe2::FixedDivisor tile_range_kl; caffe2::FixedDivisor tile_range_j; caffe2::FixedDivisor tile_range_l; - size_t range_i{}; - size_t range_j{}; - size_t range_k{}; - size_t range_l{}; - size_t tile_i{}; - size_t tile_j{}; - size_t tile_k{}; - size_t tile_l{}; + size_t range_i; + size_t range_j; + size_t range_k; + size_t range_l; + size_t tile_i; + size_t tile_j; + size_t tile_k; + size_t tile_l; }; static void compute_4d_tiled( void* context_, size_t linear_index) { - int32_t tile_index_ij = 0, tile_index_kl = 0; + int32_t tile_index_ij, tile_index_kl; const struct compute_4d_tiled_context* context = static_cast(context_); context->tile_range_kl.DivMod( static_cast(linear_index), &tile_index_ij, &tile_index_kl); - int32_t tile_index_i = 0, tile_index_j = 0; + int32_t tile_index_i, tile_index_j; context->tile_range_j.DivMod(tile_index_ij, &tile_index_i, &tile_index_j); - int32_t tile_index_k = 0, tile_index_l = 0; + int32_t tile_index_k, tile_index_l; context->tile_range_l.DivMod(tile_index_kl, &tile_index_k, &tile_index_l); const size_t max_tile_i = context->tile_i; const size_t max_tile_j = context->tile_j; diff --git a/caffe2/utils/threadpool/pthreadpool_impl.cc b/caffe2/utils/threadpool/pthreadpool_impl.cc index 79597b5a2457e..ae031ca2ae7e6 100644 --- a/caffe2/utils/threadpool/pthreadpool_impl.cc +++ b/caffe2/utils/threadpool/pthreadpool_impl.cc @@ -7,7 +7,9 @@ namespace caffe2 { namespace { static thread_local bool using_new_threadpool{false}; } -WithCastToNewThreadPool::WithCastToNewThreadPool(bool use_new_threadpool) : use_new_threadpool_(using_new_threadpool) { +WithCastToNewThreadPool::WithCastToNewThreadPool(bool use_new_threadpool) { + use_new_threadpool_ = using_new_threadpool; + using_new_threadpool = use_new_threadpool; } WithCastToNewThreadPool::~WithCastToNewThreadPool() { using_new_threadpool = use_new_threadpool_; diff --git a/test/cpp/jit/test_custom_class.cpp b/test/cpp/jit/test_custom_class.cpp index 42234cddf4e5d..f7fe339b56143 100644 --- a/test/cpp/jit/test_custom_class.cpp +++ b/test/cpp/jit/test_custom_class.cpp @@ -1,6 +1,5 @@ #include -#include #include #include #include diff --git a/torch/csrc/jit/mobile/compatibility/backport_manager.cpp b/torch/csrc/jit/mobile/compatibility/backport_manager.cpp index 17145fee78a6b..3d71329e61240 100644 --- a/torch/csrc/jit/mobile/compatibility/backport_manager.cpp +++ b/torch/csrc/jit/mobile/compatibility/backport_manager.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include diff --git a/torch/csrc/jit/mobile/compatibility/model_compatibility.cpp b/torch/csrc/jit/mobile/compatibility/model_compatibility.cpp index d87660238232a..b8b1ca6adc0dc 100644 --- a/torch/csrc/jit/mobile/compatibility/model_compatibility.cpp +++ b/torch/csrc/jit/mobile/compatibility/model_compatibility.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include // removed after using simple type_resolver/obj_loader #include #include