mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Replace whitelist with allowlist (#42067)
Summary: Fixes https://github.com/pytorch/pytorch/issues/41757 I've replaced all the whitelist with allowlist for this issue. Pull Request resolved: https://github.com/pytorch/pytorch/pull/42067 Reviewed By: pbelevich Differential Revision: D22791690 Pulled By: malfet fbshipit-source-id: 638c13cf49915f5c83bd79c7f4a39b8390cc15b4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1a8269a566
commit
b282297559
@ -449,7 +449,7 @@ enable_testing()
|
|||||||
|
|
||||||
# ---[ Build variables set within the cmake tree
|
# ---[ Build variables set within the cmake tree
|
||||||
include(cmake/BuildVariables.cmake)
|
include(cmake/BuildVariables.cmake)
|
||||||
set(CAFFE2_WHITELIST "" CACHE STRING "A whitelist file of files that one should build.")
|
set(CAFFE2_ALLOWLIST "" CACHE STRING "A allowlist file of files that one should build.")
|
||||||
|
|
||||||
# Set default build type
|
# Set default build type
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
@ -499,8 +499,8 @@ if(USE_VULKAN_SHADERC_RUNTIME)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_VULKAN_SHADERC_RUNTIME")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_VULKAN_SHADERC_RUNTIME")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---[ Whitelist file if whitelist is specified
|
# ---[ Allowlist file if allowlist is specified
|
||||||
include(cmake/Whitelist.cmake)
|
include(cmake/Allowlist.cmake)
|
||||||
|
|
||||||
# ---[ Set link flag, handle additional deps for gcc 4.8 and above
|
# ---[ Set link flag, handle additional deps for gcc 4.8 and above
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.0 AND NOT ANDROID)
|
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.0 AND NOT ANDROID)
|
||||||
|
@ -142,12 +142,12 @@ if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
|||||||
add_subdirectory(transforms)
|
add_subdirectory(transforms)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Advanced: if we have white list specified, we will do intersections for all
|
# Advanced: if we have allow list specified, we will do intersections for all
|
||||||
# main lib srcs.
|
# main lib srcs.
|
||||||
if(CAFFE2_WHITELISTED_FILES)
|
if(CAFFE2_ALLOWLISTED_FILES)
|
||||||
caffe2_do_whitelist(Caffe2_CPU_SRCS CAFFE2_WHITELISTED_FILES)
|
caffe2_do_allowlist(Caffe2_CPU_SRCS CAFFE2_ALLOWLISTED_FILES)
|
||||||
caffe2_do_whitelist(Caffe2_GPU_SRCS CAFFE2_WHITELISTED_FILES)
|
caffe2_do_allowlist(Caffe2_GPU_SRCS CAFFE2_ALLOWLISTED_FILES)
|
||||||
caffe2_do_whitelist(Caffe2_HIP_SRCS CAFFE2_WHITELISTED_FILES)
|
caffe2_do_allowlist(Caffe2_HIP_SRCS CAFFE2_ALLOWLISTED_FILES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Debug messages - if you want to get a list of source files, enable the
|
# Debug messages - if you want to get a list of source files, enable the
|
||||||
|
32
cmake/Allowlist.cmake
Normal file
32
cmake/Allowlist.cmake
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
if(__caffe2_allowlist_included)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(__caffe2_allowlist_included TRUE)
|
||||||
|
|
||||||
|
set(CAFFE2_ALLOWLISTED_FILES)
|
||||||
|
if(NOT CAFFE2_ALLOWLIST)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# First read the allowlist file and break it by line.
|
||||||
|
file(READ "${CAFFE2_ALLOWLIST}" allowlist_content)
|
||||||
|
# Convert file contents into a CMake list
|
||||||
|
string(REGEX REPLACE "\n" ";" allowlist_content ${allowlist_content})
|
||||||
|
|
||||||
|
foreach(item ${allowlist_content})
|
||||||
|
file(GLOB_RECURSE tmp ${item})
|
||||||
|
set(CAFFE2_ALLOWLISTED_FILES ${CAFFE2_ALLOWLISTED_FILES} ${tmp})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
macro(caffe2_do_allowlist output allowlist)
|
||||||
|
set(_tmp)
|
||||||
|
foreach(item ${${output}})
|
||||||
|
list(FIND ${allowlist} ${item} _index)
|
||||||
|
if(${_index} GREATER -1)
|
||||||
|
set(_tmp ${_tmp} ${item})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(${output} ${_tmp})
|
||||||
|
endmacro()
|
@ -1,32 +0,0 @@
|
|||||||
|
|
||||||
if(__caffe2_whitelist_included)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(__caffe2_whitelist_included TRUE)
|
|
||||||
|
|
||||||
set(CAFFE2_WHITELISTED_FILES)
|
|
||||||
if(NOT CAFFE2_WHITELIST)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# First read the whitelist file and break it by line.
|
|
||||||
file(READ "${CAFFE2_WHITELIST}" whitelist_content)
|
|
||||||
# Convert file contents into a CMake list
|
|
||||||
string(REGEX REPLACE "\n" ";" whitelist_content ${whitelist_content})
|
|
||||||
|
|
||||||
foreach(item ${whitelist_content})
|
|
||||||
file(GLOB_RECURSE tmp ${item})
|
|
||||||
set(CAFFE2_WHITELISTED_FILES ${CAFFE2_WHITELISTED_FILES} ${tmp})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
macro(caffe2_do_whitelist output whitelist)
|
|
||||||
set(_tmp)
|
|
||||||
foreach(item ${${output}})
|
|
||||||
list(FIND ${whitelist} ${item} _index)
|
|
||||||
if(${_index} GREATER -1)
|
|
||||||
set(_tmp ${_tmp} ${item})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
set(${output} ${_tmp})
|
|
||||||
endmacro()
|
|
Reference in New Issue
Block a user