Skip to content

Commit

Permalink
"whitelist" -> "allowlist" (#51375)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #51375

Test Plan: Sandcastle tests

Reviewed By: iseeyuan

Differential Revision: D26150609

fbshipit-source-id: 1ca17bc8943598a42f028005d1f6d3f362fe2659
  • Loading branch information
r-barnes authored and facebook-github-bot committed Feb 3, 2021
1 parent c791a30 commit b283ac6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions aten/src/ATen/core/op_registration/op_whitelist.h
Expand Up @@ -10,7 +10,7 @@
* set of operators (+ dependencies) included.
*
* - Build with -DTORCH_OPERATOR_WHITELIST="aten::add;aten::sub" and only these
* two ops will be included in your build. The whitelist records operators
* two ops will be included in your build. The allowlist records operators
* only, no overloads; if you include aten::add, all overloads of aten::add
* will be included.
*
Expand All @@ -19,9 +19,9 @@
* operator functions that weren't registered.
* See Note [Selective build] for more details
*
* WARNING: The whitelist mechanism doesn't work for all ways you could go about
* WARNING: The allowlist mechanism doesn't work for all ways you could go about
* registering an operator. If the dispatch key / operator name is not
* sufficiently obvious at compile time, then the whitelisting mechanism
* sufficiently obvious at compile time, then the allowlisting mechanism
* will fail (and the operator will be included in the binary anyway).
*/

Expand All @@ -33,21 +33,21 @@ namespace c10 {

namespace impl {

// returns true iff whitelist contains item
// returns true iff allowlist contains item
// op_whitelist_contains("a;bc;d", "bc") == true
constexpr bool op_whitelist_contains(string_view whitelist, string_view item) {
constexpr bool op_whitelist_contains(string_view allowlist, string_view item) {
//Choose a really big value for next so that if something goes wrong
//this code will blow up in a hopefully detectable way.
size_t next = std::numeric_limits<size_t>::max();
for (size_t cur = 0; cur <= whitelist.size(); cur = next) {
next = whitelist.find(';', cur);
for (size_t cur = 0; cur <= allowlist.size(); cur = next) {
next = allowlist.find(';', cur);
if (next != string_view::npos) {
if (whitelist.substr(cur, next - cur).compare(item) == 0) {
if (allowlist.substr(cur, next - cur).compare(item) == 0) {
return true;
}
next++;
} else {
if (whitelist.substr(cur).compare(item) == 0) {
if (allowlist.substr(cur).compare(item) == 0) {
return true;
}
break;
Expand All @@ -56,7 +56,7 @@ constexpr bool op_whitelist_contains(string_view whitelist, string_view item) {
return false;
}

// Returns true iff the given op name is on the whitelist
// Returns true iff the given op name is on the allowlist
// and should be registered
constexpr bool op_whitelist_check(string_view op_name) {
assert(op_name.find("::") != string_view::npos);
Expand All @@ -68,16 +68,16 @@ constexpr bool op_whitelist_check(string_view op_name) {
return op_whitelist_contains(
C10_STRINGIZE(TORCH_OPERATOR_WHITELIST),
// This function is majorly used for mobile selective build with
// root operators, where the overload is included in the whitelist.
// root operators, where the overload is included in the allowlist.
op_name);
// // Strip overload name (as whitelist doesn't contain overloads)
// // Strip overload name (as allowlist doesn't contain overloads)
// // Another function based on this may be added when there's usage
// // on op names without overload.
// OperatorNameView::parse(op_name).name);
#endif
}

// Returns true iff the given schema string is on the whitelist
// Returns true iff the given schema string is on the allowlist
// and should be registered
constexpr bool schema_whitelist_check(string_view schema) {
#if defined(TORCH_FORCE_SCHEMA_REGISTRATION)
Expand All @@ -88,12 +88,12 @@ constexpr bool schema_whitelist_check(string_view schema) {
}

// schema_whitelist_check() implicitly depends on a macro, TORCH_OPERATOR_WHITELIST.
// Add this API to pass arbitrary whitelist.
constexpr bool op_whitelist_contains_name_in_schema(string_view whitelist, string_view schema) {
return op_whitelist_contains(whitelist, schema.substr(0, schema.find("(")));
// Add this API to pass arbitrary allowlist.
constexpr bool op_whitelist_contains_name_in_schema(string_view allowlist, string_view schema) {
return op_whitelist_contains(allowlist, schema.substr(0, schema.find("(")));
}

// Returns true iff the given dispatch key is on the whitelist
// Returns true iff the given dispatch key is on the allowlist
// and should be registered. When we turn this on, the list of valid
// mobile dispatch keys is hard coded (but you need to make sure
// that you have the correct set of dispatch keys for this).
Expand Down
2 changes: 1 addition & 1 deletion torch/quantization/quantization_mappings.py
Expand Up @@ -89,7 +89,7 @@
nn.RNNCell: nnqd.RNNCell,
}

# Whitelist for propagating the qconfig
# Allowlist for propagating the qconfig
_INCLUDE_QCONFIG_PROPAGATE_LIST : Set[Callable] = {
nn.Sequential,
}
Expand Down

0 comments on commit b283ac6

Please sign in to comment.