[BE] Cleanup CMake flag suppressions (#97584)

Use `append_cxx_flag_if_supported` to determine whether or not `-Werror` is supported
Do not suppress deprecation warnings if glog is not used/installed, as the way check is written right now, it will suppress deprecations even if `glog` is not installed.
Similarly, do not suppress deprecations on MacOS simply because we are compiling with protobuf.
Fix deprecation warnings in:
 - MPS by replacing `MTLResourceOptionCPUCacheModeDefault`->`MTLResourceCPUCacheModeDefaultCache`
 - In GTests by replacing `TYPED_TEST_CASE`->`TYPED_TEST_SUITE`
 - In `codegen/onednn/interface.cpp`, by using passing `Stack` by reference rathern than pointer.

Do not guard calls to `append_cxx_flag_if_supported` with `if(CLANG)` or `if(GCC)`.
Fix some deprecated calls in `Metal` hide more complex exception under `C10_CLANG_DIAGNOSTIC_IGNORE`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/97584
Approved by: https://github.com/kit1980
This commit is contained in:
Nikita Shulga 2023-03-27 18:46:09 +00:00 committed by PyTorch MergeBot
parent 345714e372
commit 96e3b3ac72
19 changed files with 89 additions and 93 deletions

View File

@ -808,7 +808,6 @@ if(NOT MSVC)
append_cxx_flag_if_supported("-Wno-unused-result" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wno-unused-result" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-strict-overflow" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wno-strict-overflow" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-strict-aliasing" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-error=deprecated-declarations" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wvla-extension" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wvla-extension" CMAKE_CXX_FLAGS)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
string(APPEND CMAKE_CXX_FLAGS " -Wno-range-loop-analysis") string(APPEND CMAKE_CXX_FLAGS " -Wno-range-loop-analysis")
@ -854,19 +853,13 @@ if(NOT MSVC)
append_cxx_flag_if_supported("-Wno-error=pedantic" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wno-error=pedantic" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-error=old-style-cast" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wno-error=old-style-cast" CMAKE_CXX_FLAGS)
# These flags are not available in GCC-4.8.5. Set only when using clang. append_cxx_flag_if_supported("-Wconstant-conversion" CMAKE_CXX_FLAGS)
# Compared against https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Option-Summary.html append_cxx_flag_if_supported("-Wno-invalid-partial-specialization" CMAKE_CXX_FLAGS)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") append_cxx_flag_if_supported("-Wno-unused-private-field" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wconstant-conversion" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wno-aligned-allocation-unavailable" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-invalid-partial-specialization" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wno-missing-braces" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-unused-private-field" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Wunused-lambda-capture" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-aligned-allocation-unavailable" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-Qunused-arguments" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-missing-braces" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wunused-lambda-capture" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Qunused-arguments" CMAKE_CXX_FLAGS)
if(${USE_COLORIZE_OUTPUT})
endif()
endif()
if(${USE_COLORIZE_OUTPUT}) if(${USE_COLORIZE_OUTPUT})
append_cxx_flag_if_supported("-fcolor-diagnostics" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-fcolor-diagnostics" CMAKE_CXX_FLAGS)
@ -879,17 +872,13 @@ if(NOT MSVC)
string(APPEND CMAKE_CXX_FLAGS " -faligned-new") string(APPEND CMAKE_CXX_FLAGS " -faligned-new")
endif() endif()
if(WERROR) if(WERROR)
check_cxx_compiler_flag("-Werror" COMPILER_SUPPORT_WERROR) append_cxx_flag_if_supported("-Werror" CMAKE_CXX_FLAGS)
if(NOT COMPILER_SUPPORT_WERROR) if(NOT COMPILER_SUPPORT_WERROR)
set(WERROR FALSE) set(WERROR FALSE)
else()
string(APPEND CMAKE_CXX_FLAGS " -Werror")
endif() endif()
endif(WERROR)
if(NOT APPLE)
append_cxx_flag_if_supported("-Wno-unused-but-set-variable" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
endif() endif()
append_cxx_flag_if_supported("-Wno-unused-but-set-variable" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fno-omit-frame-pointer -O0") string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0") string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS) append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)

View File

@ -53,9 +53,12 @@ using namespace at::native::metal;
isOperatingSystemAtLeastVersion:supportedVer]) { isOperatingSystemAtLeastVersion:supportedVer]) {
return false; return false;
} }
C10_CLANG_DIAGNOSTIC_PUSH()
C10_CLANG_DIAGNOSTIC_IGNORE("-Wdeprecated-declarations")
if (![_device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v3]) { if (![_device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v3]) {
return false; return false;
} }
C10_CLANG_DIAGNOSTIC_POP()
#else #else
return false; return false;
#endif #endif
@ -136,7 +139,7 @@ using namespace at::native::metal;
- (id<MTLBuffer>)emptyMTLBuffer:(int64_t) size { - (id<MTLBuffer>)emptyMTLBuffer:(int64_t) size {
TORCH_CHECK(_device); TORCH_CHECK(_device);
id<MTLBuffer> buffer = [_device newBufferWithLength:size id<MTLBuffer> buffer = [_device newBufferWithLength:size
options:MTLResourceOptionCPUCacheModeWriteCombined]; options:MTLResourceCPUCacheModeWriteCombined];
return buffer; return buffer;
} }

View File

@ -1,6 +1,11 @@
#import <ATen/native/metal/MetalContext.h> #import <ATen/native/metal/MetalContext.h>
#import <ATen/native/metal/mpscnn/MPSCNNNeuronOp.h> #import <ATen/native/metal/mpscnn/MPSCNNNeuronOp.h>
#include <c10/macros/Macros.h>
C10_CLANG_DIAGNOSTIC_PUSH()
C10_CLANG_DIAGNOSTIC_IGNORE("-Wdeprecated-declarations")
@implementation MPSCNNNeuronOp @implementation MPSCNNNeuronOp
+ (MPSCNNNeuronHardSigmoid*)hardSigmoid API_AVAILABLE(ios(11.0), macos(10.13)) { + (MPSCNNNeuronHardSigmoid*)hardSigmoid API_AVAILABLE(ios(11.0), macos(10.13)) {
@ -70,6 +75,8 @@
@end @end
C10_CLANG_DIAGNOSTIC_POP()
API_AVAILABLE(ios(11.3), macos(10.13), macCatalyst(13.0)) API_AVAILABLE(ios(11.3), macos(10.13), macCatalyst(13.0))
@implementation MPSCNNNeuronOpDescriptor @implementation MPSCNNNeuronOpDescriptor

View File

@ -36,7 +36,7 @@ MPSImage* createStaticImage(const float* src, IntArrayRef sizes) {
int64_t size_bytes = c10::multiply_integers(sizes) * sizeof(float); int64_t size_bytes = c10::multiply_integers(sizes) * sizeof(float);
id<MTLBuffer> buff = [[MetalContext sharedInstance].device id<MTLBuffer> buff = [[MetalContext sharedInstance].device
newBufferWithLength:size_bytes newBufferWithLength:size_bytes
options:MTLResourceOptionCPUCacheModeWriteCombined]; options:MTLResourceCPUCacheModeWriteCombined];
memcpy(buff.contents, src, size_bytes); memcpy(buff.contents, src, size_bytes);
MPSImage* output = createStaticImage(sizes); MPSImage* output = createStaticImage(sizes);
id<MTLComputePipelineState> state = [[MetalContext sharedInstance] id<MTLComputePipelineState> state = [[MetalContext sharedInstance]
@ -171,7 +171,7 @@ void copyImageToFloatBuffer(float* dst, MPSImage* image) {
int64_t size_bytes = c10::multiply_integers([image sizes]) * sizeof(float); int64_t size_bytes = c10::multiply_integers([image sizes]) * sizeof(float);
id<MTLBuffer> buffer = [[MetalContext sharedInstance].device id<MTLBuffer> buffer = [[MetalContext sharedInstance].device
newBufferWithLength:size_bytes newBufferWithLength:size_bytes
options:MTLResourceOptionCPUCacheModeDefault]; options:MTLResourceCPUCacheModeDefaultCache];
id<MTLCommandBuffer> cb = id<MTLCommandBuffer> cb =
[MetalContext sharedInstance].commandQueue.commandBuffer; [MetalContext sharedInstance].commandQueue.commandBuffer;

View File

@ -33,7 +33,7 @@ Tensor cat_batch(const Tensor& tensor, const ITensorListRef& tensors, MetalTenso
X, "copy_offset", "copy_offset_nonarray")]; X, "copy_offset", "copy_offset_nonarray")];
id<MTLBuffer> offsetBuffer = [[MetalContext sharedInstance].device id<MTLBuffer> offsetBuffer = [[MetalContext sharedInstance].device
newBufferWithLength:1 * sizeof(ushort) newBufferWithLength:1 * sizeof(ushort)
options:MTLResourceOptionCPUCacheModeWriteCombined]; options:MTLResourceCPUCacheModeWriteCombined];
ushort* offsetBufferPtr = (ushort*)[offsetBuffer contents]; ushort* offsetBufferPtr = (ushort*)[offsetBuffer contents];
offsetBufferPtr[0] = cat_dim4_pointer; offsetBufferPtr[0] = cat_dim4_pointer;
@ -91,7 +91,7 @@ Tensor cat_feature(const Tensor& tensor, const ITensorListRef& tensors, MetalTen
]]; ]];
id<MTLBuffer> offsetBuffer = [[MetalContext sharedInstance].device id<MTLBuffer> offsetBuffer = [[MetalContext sharedInstance].device
newBufferWithLength:6 * sizeof(ushort) newBufferWithLength:6 * sizeof(ushort)
options:MTLResourceOptionCPUCacheModeWriteCombined]; options:MTLResourceCPUCacheModeWriteCombined];
ushort* offsetBufferPtr = (ushort*)[offsetBuffer contents]; ushort* offsetBufferPtr = (ushort*)[offsetBuffer contents];
offsetBufferPtr[0] = (X.featureChannels + tex_offset + 3) / 4; offsetBufferPtr[0] = (X.featureChannels + tex_offset + 3) / 4;
offsetBufferPtr[1] = (Y.featureChannels + 3) / 4; offsetBufferPtr[1] = (Y.featureChannels + 3) / 4;
@ -141,7 +141,7 @@ Tensor cat_feature(const Tensor& tensor, const ITensorListRef& tensors, MetalTen
]]; ]];
id<MTLBuffer> offsetBuffer = [[MetalContext sharedInstance].device id<MTLBuffer> offsetBuffer = [[MetalContext sharedInstance].device
newBufferWithLength:2 * sizeof(ushort) newBufferWithLength:2 * sizeof(ushort)
options:MTLResourceOptionCPUCacheModeWriteCombined]; options:MTLResourceCPUCacheModeWriteCombined];
ushort* offsetBufferPtr = (ushort*)[offsetBuffer contents]; ushort* offsetBufferPtr = (ushort*)[offsetBuffer contents];
offsetBufferPtr[0] = channel_offset / 4; offsetBufferPtr[0] = channel_offset / 4;
offsetBufferPtr[1] = (Y.featureChannels + 3) / 4; offsetBufferPtr[1] = (Y.featureChannels + 3) / 4;

View File

@ -19,7 +19,7 @@ template<typename T>
id<MTLBuffer> _makeMTLBuffer(const std::vector<T>& src) { id<MTLBuffer> _makeMTLBuffer(const std::vector<T>& src) {
id<MTLBuffer> buffer = [[MetalContext sharedInstance].device id<MTLBuffer> buffer = [[MetalContext sharedInstance].device
newBufferWithLength:src.size() * sizeof(T) newBufferWithLength:src.size() * sizeof(T)
options:MTLResourceOptionCPUCacheModeWriteCombined]; options:MTLResourceCPUCacheModeWriteCombined];
memcpy(buffer.contents, src.data(), src.size() * sizeof(T)); memcpy(buffer.contents, src.data(), src.size() * sizeof(T));
return buffer; return buffer;
} }

View File

@ -126,7 +126,7 @@ static at::Tensor& copy_from_mps_(at::Tensor& dst_, const at::Tensor& src_, bool
size_t dst_tensor_nbytes = dst.nbytes(); size_t dst_tensor_nbytes = dst.nbytes();
@autoreleasepool { @autoreleasepool {
MTLResourceOptions options = MTLResourceOptionCPUCacheModeDefault | MTLResourceStorageModeShared; MTLResourceOptions options = MTLResourceCPUCacheModeDefaultCache | MTLResourceStorageModeShared;
NSUInteger alignedLength = 0; NSUInteger alignedLength = 0;
void* host_dst = dst.storage().data(); void* host_dst = dst.storage().data();
@ -189,7 +189,7 @@ static void copy_to_mps_stride_contig(at::Tensor& dst, const at::Tensor& src, bo
TORCH_INTERNAL_ASSERT(src.dtype() == dst.dtype() && src.strides() == dst.strides() && is_strided_contiguous(src)); TORCH_INTERNAL_ASSERT(src.dtype() == dst.dtype() && src.strides() == dst.strides() && is_strided_contiguous(src));
@autoreleasepool { @autoreleasepool {
MTLResourceOptions options = MTLResourceOptionCPUCacheModeDefault | MTLResourceStorageModeShared; MTLResourceOptions options = MTLResourceCPUCacheModeDefaultCache | MTLResourceStorageModeShared;
NSUInteger alignedLength = 0; NSUInteger alignedLength = 0;
NSUInteger sourceOffset = 0; NSUInteger sourceOffset = 0;

View File

@ -372,7 +372,7 @@ TORCH_IMPL_FUNC(cumsum_out_mps)
// issue #103810551: cumsum is horribly broken for int8, int16 and as chances for overflow is pretty high, cast to // issue #103810551: cumsum is horribly broken for int8, int16 and as chances for overflow is pretty high, cast to
// int32 fixed in macOS 13.3 // int32 fixed in macOS 13.3
bool castInputData = (isIntegralType(input.scalar_type()) && input.scalar_type() != ScalarType::Int && bool castInputData = (isIntegralType(input.scalar_type(), false) && input.scalar_type() != ScalarType::Int &&
input.scalar_type() != ScalarType::Long); input.scalar_type() != ScalarType::Long);
TORCH_CHECK(macOS13_3_plus || input.scalar_type() != ScalarType::Long, TORCH_CHECK(macOS13_3_plus || input.scalar_type() != ScalarType::Long,

View File

@ -66,7 +66,7 @@ using ExclusivelyOwnedTypes = ::testing::Types<
caffe2::Tensor caffe2::Tensor
>; >;
TYPED_TEST_CASE(ExclusivelyOwnedTest, ExclusivelyOwnedTypes); TYPED_TEST_SUITE(ExclusivelyOwnedTest, ExclusivelyOwnedTypes);
TYPED_TEST(ExclusivelyOwnedTest, DefaultConstructor) { TYPED_TEST(ExclusivelyOwnedTest, DefaultConstructor) {
c10::ExclusivelyOwned<TypeParam> defaultConstructed; c10::ExclusivelyOwned<TypeParam> defaultConstructed;

View File

@ -197,7 +197,7 @@ using MaybeOwnedTypes = ::testing::Types<
c10::IValue c10::IValue
>; >;
TYPED_TEST_CASE(MaybeOwnedTest, MaybeOwnedTypes); TYPED_TEST_SUITE(MaybeOwnedTest, MaybeOwnedTypes);
TYPED_TEST(MaybeOwnedTest, SimpleDereferencingString) { TYPED_TEST(MaybeOwnedTest, SimpleDereferencingString) {
assertBorrow(this->borrowed, this->borrowFrom); assertBorrow(this->borrowed, this->borrowFrom);

View File

@ -70,35 +70,35 @@ namespace {
using FloatIntTestedTypes = ::testing::Types<vfloat, vdouble, vcomplex, vcomplexDbl, vlong, vint, vshort>; using FloatIntTestedTypes = ::testing::Types<vfloat, vdouble, vcomplex, vcomplexDbl, vlong, vint, vshort>;
using ComplexTypes = ::testing::Types<vcomplex, vcomplexDbl>; using ComplexTypes = ::testing::Types<vcomplex, vcomplexDbl>;
using BFloatTestedTypes = ::testing::Types<vBFloat16>; using BFloatTestedTypes = ::testing::Types<vBFloat16>;
TYPED_TEST_CASE(Memory, ALLTestedTypes); TYPED_TEST_SUITE(Memory, ALLTestedTypes);
TYPED_TEST_CASE(Arithmetics, FloatIntTestedTypes); TYPED_TEST_SUITE(Arithmetics, FloatIntTestedTypes);
TYPED_TEST_CASE(Comparison, RealFloatIntTestedTypes); TYPED_TEST_SUITE(Comparison, RealFloatIntTestedTypes);
TYPED_TEST_CASE(Bitwise, FloatIntTestedTypes); TYPED_TEST_SUITE(Bitwise, FloatIntTestedTypes);
TYPED_TEST_CASE(MinMax, RealFloatIntTestedTypes); TYPED_TEST_SUITE(MinMax, RealFloatIntTestedTypes);
TYPED_TEST_CASE(Nan, RealFloatTestedTypes); TYPED_TEST_SUITE(Nan, RealFloatTestedTypes);
TYPED_TEST_CASE(Interleave, RealFloatIntTestedTypes); TYPED_TEST_SUITE(Interleave, RealFloatIntTestedTypes);
TYPED_TEST_CASE(SignManipulation, FloatIntTestedTypes); TYPED_TEST_SUITE(SignManipulation, FloatIntTestedTypes);
TYPED_TEST_CASE(Rounding, RealFloatTestedTypes); TYPED_TEST_SUITE(Rounding, RealFloatTestedTypes);
TYPED_TEST_CASE(SqrtAndReciprocal, FloatTestedTypes); TYPED_TEST_SUITE(SqrtAndReciprocal, FloatTestedTypes);
TYPED_TEST_CASE(SqrtAndReciprocalReal, RealFloatTestedTypes); TYPED_TEST_SUITE(SqrtAndReciprocalReal, RealFloatTestedTypes);
TYPED_TEST_CASE(FractionAndRemainderReal, RealFloatTestedTypes); TYPED_TEST_SUITE(FractionAndRemainderReal, RealFloatTestedTypes);
TYPED_TEST_CASE(Trigonometric, RealFloatTestedTypes); TYPED_TEST_SUITE(Trigonometric, RealFloatTestedTypes);
TYPED_TEST_CASE(ErrorFunctions, RealFloatTestedTypes); TYPED_TEST_SUITE(ErrorFunctions, RealFloatTestedTypes);
TYPED_TEST_CASE(Exponents, RealFloatTestedTypes); TYPED_TEST_SUITE(Exponents, RealFloatTestedTypes);
TYPED_TEST_CASE(Hyperbolic, RealFloatTestedTypes); TYPED_TEST_SUITE(Hyperbolic, RealFloatTestedTypes);
TYPED_TEST_CASE(InverseTrigonometricReal, RealFloatTestedTypes); TYPED_TEST_SUITE(InverseTrigonometricReal, RealFloatTestedTypes);
TYPED_TEST_CASE(InverseTrigonometric, FloatTestedTypes); TYPED_TEST_SUITE(InverseTrigonometric, FloatTestedTypes);
TYPED_TEST_CASE(LGamma, RealFloatTestedTypes); TYPED_TEST_SUITE(LGamma, RealFloatTestedTypes);
TYPED_TEST_CASE(Logarithm, FloatTestedTypes); TYPED_TEST_SUITE(Logarithm, FloatTestedTypes);
TYPED_TEST_CASE(LogarithmReals, RealFloatTestedTypes); TYPED_TEST_SUITE(LogarithmReals, RealFloatTestedTypes);
TYPED_TEST_CASE(Pow, RealFloatTestedTypes); TYPED_TEST_SUITE(Pow, RealFloatTestedTypes);
TYPED_TEST_CASE(RealTests, RealFloatTestedTypes); TYPED_TEST_SUITE(RealTests, RealFloatTestedTypes);
TYPED_TEST_CASE(RangeFactories, FloatIntTestedTypes); TYPED_TEST_SUITE(RangeFactories, FloatIntTestedTypes);
TYPED_TEST_CASE(BitwiseFloatsAdditional, RealFloatTestedTypes); TYPED_TEST_SUITE(BitwiseFloatsAdditional, RealFloatTestedTypes);
TYPED_TEST_CASE(BitwiseFloatsAdditional2, FloatTestedTypes); TYPED_TEST_SUITE(BitwiseFloatsAdditional2, FloatTestedTypes);
TYPED_TEST_CASE(QuantizationTests, QuantTestedTypes); TYPED_TEST_SUITE(QuantizationTests, QuantTestedTypes);
TYPED_TEST_CASE(FunctionalTests, RealFloatIntTestedTypes); TYPED_TEST_SUITE(FunctionalTests, RealFloatIntTestedTypes);
TYPED_TEST_CASE(FunctionalBF16Tests, BFloatTestedTypes); TYPED_TEST_SUITE(FunctionalBF16Tests, BFloatTestedTypes);
TYPED_TEST(Memory, UnAlignedLoadStore) { TYPED_TEST(Memory, UnAlignedLoadStore) {
using vec = TypeParam; using vec = TypeParam;
using VT = ValueType<TypeParam>; using VT = ValueType<TypeParam>;

View File

@ -180,7 +180,7 @@ TEST_P(BFloat16Test, BFloat16RNETest) {
EXPECT_EQ(GetParam().rne, rounded); EXPECT_EQ(GetParam().rne, rounded);
} }
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_SUITE_P(
BFloat16Test_Instantiation, BFloat16Test_Instantiation,
BFloat16Test, BFloat16Test,
::testing::Values( ::testing::Values(

View File

@ -63,7 +63,7 @@ static_assert(
sizeof(c10::optional<c10::IntArrayRef>) == sizeof(c10::IntArrayRef), sizeof(c10::optional<c10::IntArrayRef>) == sizeof(c10::IntArrayRef),
"c10::optional<IntArrayRef> should be size-optimized"); "c10::optional<IntArrayRef> should be size-optimized");
TYPED_TEST_CASE(OptionalTest, OptionalTypes); TYPED_TEST_SUITE(OptionalTest, OptionalTypes);
TYPED_TEST(OptionalTest, Empty) { TYPED_TEST(OptionalTest, Empty) {
typename TestFixture::optional empty; typename TestFixture::optional empty;
@ -111,11 +111,11 @@ TEST_P(SelfCompareTest, SelfCompare) {
EXPECT_THAT(x, Not(Gt(x))); EXPECT_THAT(x, Not(Gt(x)));
} }
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_SUITE_P(
nullopt, nullopt,
SelfCompareTest, SelfCompareTest,
testing::Values(c10::nullopt)); testing::Values(c10::nullopt));
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_SUITE_P(
int, int,
SelfCompareTest, SelfCompareTest,
testing::Values(c10::make_optional(2))); testing::Values(c10::make_optional(2)));
@ -158,7 +158,7 @@ using CmpTestTypes = testing::Types<
std::pair<long, c10::optional<int>>>; std::pair<long, c10::optional<int>>>;
template <typename T> template <typename T>
class CmpTest : public testing::Test {}; class CmpTest : public testing::Test {};
TYPED_TEST_CASE(CmpTest, CmpTestTypes); TYPED_TEST_SUITE(CmpTest, CmpTestTypes);
TYPED_TEST(CmpTest, Cmp) { TYPED_TEST(CmpTest, Cmp) {
TypeParam pair = {2, 3}; TypeParam pair = {2, 3};

View File

@ -13,24 +13,22 @@ include(CMakePushCheckState)
set(CAFFE2_USE_EXCEPTION_PTR 1) set(CAFFE2_USE_EXCEPTION_PTR 1)
# ---[ Check if we want to turn off deprecated warning due to glog. # ---[ Check if we want to turn off deprecated warning due to glog.
# Note(jiayq): on ubuntu 14.04, the default glog install uses ext/hash_set that if(USE_GLOG)
# is being deprecated. As a result, we will test if this is the environment we cmake_push_check_state(RESET)
# are building under. If yes, we will turn off deprecation warning for a set(CMAKE_REQUIRED_FLAGS "-std=c++14")
# cleaner build output. CHECK_CXX_SOURCE_COMPILES(
cmake_push_check_state(RESET) "#include <glog/stl_logging.h>
set(CMAKE_REQUIRED_FLAGS "-std=c++14") int main(int argc, char** argv) {
CHECK_CXX_SOURCE_COMPILES( return 0;
"#include <glog/stl_logging.h> }" CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING
int main(int argc, char** argv) { FAIL_REGEX ".*-Wno-deprecated.*")
return 0;
}" CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING
FAIL_REGEX ".*-Wno-deprecated.*")
if(NOT CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING AND NOT MSVC) if(NOT CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING AND NOT MSVC)
message(STATUS "Turning off deprecation warning due to glog.") message(STATUS "Turning off deprecation warning due to glog.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
endif()
cmake_pop_check_state()
endif() endif()
cmake_pop_check_state()
# ---[ Check if the compiler has AVX/AVX2 support. We only check AVX2. # ---[ Check if the compiler has AVX/AVX2 support. We only check AVX2.
if(NOT INTERN_BUILD_MOBILE) if(NOT INTERN_BUILD_MOBILE)

View File

@ -5,11 +5,6 @@ macro(custom_protobuf_find)
option(protobuf_BUILD_TESTS "" OFF) option(protobuf_BUILD_TESTS "" OFF)
option(protobuf_BUILD_EXAMPLES "" OFF) option(protobuf_BUILD_EXAMPLES "" OFF)
option(protobuf_WITH_ZLIB "" OFF) option(protobuf_WITH_ZLIB "" OFF)
if(APPLE)
# Protobuf generated files triggers a deprecated atomic operation warning
# so we turn it off here.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()
if(${CAFFE2_LINK_LOCAL_PROTOBUF}) if(${CAFFE2_LINK_LOCAL_PROTOBUF})
# If we are going to link protobuf locally, we will need to turn off # If we are going to link protobuf locally, we will need to turn off
# shared libs build for protobuf. # shared libs build for protobuf.

View File

@ -445,7 +445,6 @@ function(torch_compile_options libname)
-Wno-unknown-pragmas -Wno-unknown-pragmas
-Wno-strict-overflow -Wno-strict-overflow
-Wno-strict-aliasing -Wno-strict-aliasing
-Wno-error=deprecated-declarations
# Clang has an unfixed bug leading to spurious missing braces # Clang has an unfixed bug leading to spurious missing braces
# warnings, see https://bugs.llvm.org/show_bug.cgi?id=21629 # warnings, see https://bugs.llvm.org/show_bug.cgi?id=21629
-Wno-missing-braces -Wno-missing-braces

View File

@ -2217,7 +2217,7 @@ TEST_P(LiteInterpreterDynamicTypeTestFixture, Conformance) {
} }
} }
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_SUITE_P(
PyTorch, PyTorch,
LiteInterpreterDynamicTypeTestFixture, LiteInterpreterDynamicTypeTestFixture,
::testing::Range( ::testing::Range(

View File

@ -279,6 +279,11 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(${TORCH_SRC_DIR}/csrc/utils/throughput_benchmark.cpp PROPERTIES COMPILE_FLAGS -Wno-attributes) set_source_files_properties(${TORCH_SRC_DIR}/csrc/utils/throughput_benchmark.cpp PROPERTIES COMPILE_FLAGS -Wno-attributes)
endif() endif()
if(NOT MSVC)
# cudaProfilerInitialize must go away
set_source_files_properties(${TORCH_SRC_DIR}/csrc/cuda/shared/cudart.cpp PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
endif()
# coreml # coreml
if(USE_COREML_DELEGATE) if(USE_COREML_DELEGATE)
list(APPEND TORCH_PYTHON_SRCS ${TORCH_SRC_DIR}/csrc/jit/backends/coreml/cpp/backend.cpp) list(APPEND TORCH_PYTHON_SRCS ${TORCH_SRC_DIR}/csrc/jit/backends/coreml/cpp/backend.cpp)

View File

@ -99,9 +99,9 @@ void fuseGraph(std::shared_ptr<Graph>& g) {
Operation createLlgaKernel(const Node* node) { Operation createLlgaKernel(const Node* node) {
auto kernel = std::make_shared<fuser::onednn::LlgaKernel>(node); auto kernel = std::make_shared<fuser::onednn::LlgaKernel>(node);
return [kernel](Stack* stack) { return [kernel](Stack& stack) {
RECORD_FUNCTION(kernel->debugName(), std::vector<c10::IValue>()); RECORD_FUNCTION(kernel->debugName(), std::vector<c10::IValue>());
kernel->run(*stack); kernel->run(stack);
return 0; return 0;
}; };
} }
@ -118,7 +118,7 @@ RegisterOperators oneDNNFusionGroupOp({
// But if we have any scalar inputs to guard in the future, some logic here // But if we have any scalar inputs to guard in the future, some logic here
// would have to be changed. // would have to be changed.
Operation createLlgaGuardKernel(const Node* node) { Operation createLlgaGuardKernel(const Node* node) {
return [node](Stack* stack) { return [node](Stack& stack) {
#ifdef GRAPH_DEBUG_ENABLED #ifdef GRAPH_DEBUG_ENABLED
GRAPH_DEBUG("Guarding node: ", node->kind().toQualString()); GRAPH_DEBUG("Guarding node: ", node->kind().toQualString());
#endif #endif