Check function declarations in Caffe2 code (#134925)

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/134925
Approved by: https://github.com/ezyang
This commit is contained in:
cyy
2024-09-09 05:03:29 +00:00
committed by PyTorch MergeBot
parent e6c3f58584
commit 60e8dc4374
4 changed files with 27 additions and 3 deletions

View File

@ -781,7 +781,7 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT USE_IOS AND NOT USE_COREML
set_source_files_properties(${source_file} PROPERTIES COMPILE_OPTIONS "-Wno-missing-prototypes;-Wno-error=missing-prototypes")
continue()
endif()
string(FIND "${source_file}" "caffe2" res)
string(FIND "${source_file}" "embedding_lookup_idx_avx2.cc" res)
if(res GREATER -1)
set_source_files_properties(${source_file} PROPERTIES COMPILE_OPTIONS "-Wno-missing-prototypes;-Wno-error=missing-prototypes")
endif()

View File

@ -6,6 +6,7 @@
#include <c10/util/irange.h>
#include "caffe2/perfkernels/common.h"
C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wmissing-prototypes")
namespace caffe2 {
/**
@ -125,7 +126,7 @@ static bool EmbeddingLookupGenericSlowIdx(
const float* scale_bias, \
bool normalize_by_lengths, \
OutType* out) { \
if (std::is_same<InType, uint8_t>::value) { \
if constexpr (std::is_same<InType, uint8_t>::value) { \
CAFFE_ENFORCE(scale_bias != nullptr, "scale_bias must not be nullptr"); \
} else { \
CAFFE_ENFORCE(scale_bias == nullptr, "scale_bias must be nullptr"); \
@ -231,3 +232,4 @@ EMBEDDING_IDX_SPECIALIZATION(int64_t, uint8_t, uint8_t, float, true);
#undef EMBEDDING_IDX_SPECIALIZATION
} // namespace caffe2
C10_DIAGNOSTIC_POP()

View File

@ -1,5 +1,4 @@
#include "miniz.h"
#include <iostream>
#include "caffe2/serialize/crc_alt.h"

View File

@ -9,6 +9,29 @@ namespace caffe2 {
// testing and valgrind cases to avoid protobuf appearing to "leak" memory).
TORCH_API void ShutdownProtobufLibrary();
// Caffe2 wrapper functions for protobuf's GetEmptyStringAlreadyInited()
// function used to avoid duplicated global variable in the case when protobuf
// is built with hidden visibility.
TORCH_API const ::std::string& GetEmptyStringAlreadyInited();
} // namespace caffe2
namespace ONNX_NAMESPACE {
// ONNX wrapper functions for protobuf's GetEmptyStringAlreadyInited() function
// used to avoid duplicated global variable in the case when protobuf
// is built with hidden visibility.
TORCH_API const ::std::string& GetEmptyStringAlreadyInited();
} // namespace ONNX_NAMESPACE
namespace torch {
// Caffe2 wrapper functions for protobuf's GetEmptyStringAlreadyInited()
// function used to avoid duplicated global variable in the case when protobuf
// is built with hidden visibility.
TORCH_API const ::std::string& GetEmptyStringAlreadyInited();
void ShutdownProtobufLibrary();
} // namespace torch
#endif // CAFFE2_UTILS_PROTO_WRAP_H_