Skip to content

Commit 0dc72d9

Browse files
Blacklist to Blocklist in onnxifi_transformer
1 parent c0bfa45 commit 0dc72d9

2 files changed

Lines changed: 40 additions & 40 deletions

File tree

caffe2/opt/onnxifi_transformer.cc

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,13 +1035,13 @@ NetDef OnnxifiTransformer::SubnetToOnnxifiOpViaOnnx(
10351035
bool OnnxifiTransformer::supportOpOnnx(
10361036
const caffe2::OperatorDef& op,
10371037
onnx::OnnxExporter* exporter,
1038-
const std::unordered_set<int>& blacklisted_ops,
1038+
const std::unordered_set<int>& blocklisted_ops,
10391039
onnxBackendID backend_id) const {
10401040
try {
10411041
int pos =
10421042
ArgumentHelper::GetSingleArgument<OperatorDef, int>(op, kNetPos, -1);
1043-
if (blacklisted_ops.count(pos)) {
1044-
LOG(INFO) << "Skipping blacklisted op " << op.type() << " at pos " << pos;
1043+
if (blocklisted_ops.count(pos)) {
1044+
LOG(INFO) << "Skipping blocklisted op " << op.type() << " at pos " << pos;
10451045
return false;
10461046
}
10471047
const OpSchema* schema = OpSchemaRegistry::Schema(op.type());
@@ -1136,13 +1136,13 @@ bool OnnxifiTransformer::supportOpC2(
11361136
const caffe2::OperatorDef& op,
11371137
const ShapeInfoMap& shape_hints,
11381138
const std::unordered_set<std::string>& weights,
1139-
const std::unordered_set<int>& blacklisted_ops,
1139+
const std::unordered_set<int>& blocklisted_ops,
11401140
onnxBackendID backend_id) const {
11411141
try {
11421142
int pos =
11431143
ArgumentHelper::GetSingleArgument<OperatorDef, int>(op, kNetPos, -1);
1144-
if (blacklisted_ops.count(pos)) {
1145-
LOG(INFO) << "Skipping blacklisted op " << op.type() << " at pos " << pos;
1144+
if (blocklisted_ops.count(pos)) {
1145+
LOG(INFO) << "Skipping blocklisted op " << op.type() << " at pos " << pos;
11461146
return false;
11471147
}
11481148

@@ -1248,7 +1248,7 @@ void OnnxifiTransformer::tieGatherAndSparseLengthsWeightedSumOps(
12481248
const NetDef& net,
12491249
const ShapeInfoMap& shape_hints,
12501250
const std::unordered_set<std::string>& weights,
1251-
std::unordered_set<int>* blacklisted_ops) const {
1251+
std::unordered_set<int>* blocklisted_ops) const {
12521252
std::unordered_map<std::string, int> output_pos;
12531253
onnx::OnnxExporter exporter(nullptr);
12541254
onnxBackendID backend_id = backend_ids_[idx_];
@@ -1263,8 +1263,8 @@ void OnnxifiTransformer::tieGatherAndSparseLengthsWeightedSumOps(
12631263
}
12641264
} else if (StartsWith(op.type(), "SparseLengthsWeighted")) {
12651265
auto supported = opts_.use_onnx
1266-
? supportOpOnnx(op, &exporter, *blacklisted_ops, backend_id)
1267-
: supportOpC2(op, shape_hints, weights, *blacklisted_ops, backend_id);
1266+
? supportOpOnnx(op, &exporter, *blocklisted_ops, backend_id)
1267+
: supportOpC2(op, shape_hints, weights, *blocklisted_ops, backend_id);
12681268
if (!supported && op.input_size() > 1) {
12691269
check = op.input(1);
12701270
}
@@ -1277,18 +1277,18 @@ void OnnxifiTransformer::tieGatherAndSparseLengthsWeightedSumOps(
12771277
if (it == output_pos.end()) {
12781278
continue;
12791279
}
1280-
blacklisted_ops->emplace(it->second);
1280+
blocklisted_ops->emplace(it->second);
12811281
// We know that current op is not going to be supported. Might as well
1282-
// blacklist it too
1283-
blacklisted_ops->emplace(
1282+
// blocklist it too
1283+
blocklisted_ops->emplace(
12841284
ArgumentHelper::GetSingleArgument<OperatorDef, int>(op, kNetPos, -1));
12851285
}
12861286
}
12871287
}
12881288

1289-
void OnnxifiTransformer::blacklistCpuPartition(
1289+
void OnnxifiTransformer::blocklistCpuPartition(
12901290
const NetDef& net,
1291-
std::unordered_set<int>* blacklisted_ops) const {
1291+
std::unordered_set<int>* blocklisted_ops) const {
12921292
std::unordered_set<std::string> cpu_partitions;
12931293
for (const auto& p : partition_infos_) {
12941294
if (p.device_id_size() == 0) {
@@ -1298,7 +1298,7 @@ void OnnxifiTransformer::blacklistCpuPartition(
12981298
for (const auto& op : net.op()) {
12991299
const auto& pname = op.device_option().node_name();
13001300
if (cpu_partitions.count(pname)) {
1301-
blacklisted_ops->emplace(
1301+
blocklisted_ops->emplace(
13021302
ArgumentHelper::GetSingleArgument<OperatorDef, int>(op, kNetPos, -1));
13031303
}
13041304
}
@@ -1308,10 +1308,10 @@ void OnnxifiTransformer::applyFilteringRules(
13081308
const NetDef& net,
13091309
const ShapeInfoMap& shape_hints,
13101310
const std::unordered_set<std::string>& weights,
1311-
std::unordered_set<int>* blacklisted_ops) const {
1311+
std::unordered_set<int>* blocklisted_ops) const {
13121312
tieGatherAndSparseLengthsWeightedSumOps(
1313-
net, shape_hints, weights, blacklisted_ops);
1314-
blacklistCpuPartition(net, blacklisted_ops);
1313+
net, shape_hints, weights, blocklisted_ops);
1314+
blocklistCpuPartition(net, blocklisted_ops);
13151315
}
13161316

13171317
void OnnxifiTransformer::getBackendId() {
@@ -1338,16 +1338,16 @@ void OnnxifiTransformer::getBackendId() {
13381338
NetDef OnnxifiTransformer::TransformViaC2(
13391339
NetDef* pred_net,
13401340
const std::unordered_set<std::string>& weights,
1341-
const std::unordered_set<int>& blacklisted_ops,
1341+
const std::unordered_set<int>& blocklisted_ops,
13421342
const ShapeInfoMap& shape_hints) {
13431343
onnxBackendID backend_id = backend_ids_[idx_];
13441344

13451345
auto c2_supports = [this,
13461346
&shape_hints,
1347-
&blacklisted_ops,
1347+
&blocklisted_ops,
13481348
backend_id,
13491349
&weights](const caffe2::OperatorDef& op) {
1350-
return supportOpC2(op, shape_hints, weights, blacklisted_ops, backend_id);
1350+
return supportOpC2(op, shape_hints, weights, blocklisted_ops, backend_id);
13511351
};
13521352

13531353
auto c2_converter =
@@ -1363,15 +1363,15 @@ NetDef OnnxifiTransformer::TransformViaOnnx(
13631363
Workspace* ws,
13641364
NetDef* pred_net,
13651365
const std::unordered_set<std::string>& weights,
1366-
const std::unordered_set<int>& blacklisted_ops,
1366+
const std::unordered_set<int>& blocklisted_ops,
13671367
ShapeInfoMap* shape_hints) {
13681368
onnxBackendID backend_id = backend_ids_[idx_];
13691369

13701370
// function to tell whether the ONNXIFI backend supports a given C2 op or not
13711371
onnx::OnnxExporter exporter(nullptr);
1372-
auto onnx_supports = [this, &exporter, &blacklisted_ops, backend_id](
1372+
auto onnx_supports = [this, &exporter, &blocklisted_ops, backend_id](
13731373
const caffe2::OperatorDef& op) {
1374-
return supportOpOnnx(op, &exporter, blacklisted_ops, backend_id);
1374+
return supportOpOnnx(op, &exporter, blocklisted_ops, backend_id);
13751375
};
13761376

13771377
// function to convert runnable subgraph into an onnxifi op. We need to keep
@@ -1401,7 +1401,7 @@ void OnnxifiTransformer::transform(
14011401
NetDef* pred_net,
14021402
const std::vector<std::string>& weight_names,
14031403
const ShapeInfoMap& input_shape_hints,
1404-
const std::unordered_set<int>& blacklisted_ops) {
1404+
const std::unordered_set<int>& blocklisted_ops) {
14051405
CAFFE_ENFORCE(ws);
14061406
CAFFE_ENFORCE(pred_net, "Predict net cannot be nullptr");
14071407

@@ -1462,15 +1462,15 @@ void OnnxifiTransformer::transform(
14621462
getBackendId();
14631463

14641464
// Apply some filtering rules
1465-
std::unordered_set<int> new_blacklisted_ops(
1466-
blacklisted_ops.begin(), blacklisted_ops.end());
1467-
applyFilteringRules(*pred_net, shape_hints, weights, &new_blacklisted_ops);
1465+
std::unordered_set<int> new_blocklisted_ops(
1466+
blocklisted_ops.begin(), blocklisted_ops.end());
1467+
applyFilteringRules(*pred_net, shape_hints, weights, &new_blocklisted_ops);
14681468

14691469
// Transform the net
14701470
NetDef net_opt = opts_.use_onnx
14711471
? TransformViaOnnx(
1472-
ws, pred_net, weights, new_blacklisted_ops, &shape_hints)
1473-
: TransformViaC2(pred_net, weights, new_blacklisted_ops, shape_hints);
1472+
ws, pred_net, weights, new_blocklisted_ops, &shape_hints)
1473+
: TransformViaC2(pred_net, weights, new_blocklisted_ops, shape_hints);
14741474

14751475
// Need to figure out a proper place to handle device option
14761476
net_opt.mutable_device_option()->CopyFrom(pred_net->device_option());

caffe2/opt/onnxifi_transformer.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CAFFE2_API OnnxifiTransformer final : public BackendTransformerBase {
5656
NetDef* pred_net,
5757
const std::vector<std::string>& weight_names,
5858
const ShapeInfoMap& shape_hints,
59-
const std::unordered_set<int>& blacklisted_ops) override;
59+
const std::unordered_set<int>& blocklisted_ops) override;
6060

6161
private:
6262
// Since we create new tensors during the conversion process, we actually need
@@ -89,30 +89,30 @@ class CAFFE2_API OnnxifiTransformer final : public BackendTransformerBase {
8989
NetDef TransformViaC2(
9090
NetDef* pred_net,
9191
const std::unordered_set<std::string>& weights,
92-
const std::unordered_set<int>& blacklisted_ops,
92+
const std::unordered_set<int>& blocklisted_ops,
9393
const ShapeInfoMap& shape_hints);
9494

9595
// Transform by passing ONNX proto to backend
9696
NetDef TransformViaOnnx(
9797
Workspace* ws,
9898
NetDef* pred_net,
9999
const std::unordered_set<std::string>& weights,
100-
const std::unordered_set<int>& blacklisted_ops,
100+
const std::unordered_set<int>& blocklisted_ops,
101101
ShapeInfoMap* shape_hints);
102102

103103
// Query whether an operator is supported by passing C2 protobuf
104104
bool supportOpC2(
105105
const caffe2::OperatorDef& op,
106106
const ShapeInfoMap& shape_hints,
107107
const std::unordered_set<std::string>& weights,
108-
const std::unordered_set<int>& blacklisted_ops,
108+
const std::unordered_set<int>& blocklisted_ops,
109109
onnxBackendID backend_id) const;
110110

111111
// Query whether an operator is supported by passing ONNX protobuf
112112
bool supportOpOnnx(
113113
const caffe2::OperatorDef& op,
114114
onnx::OnnxExporter* exporter,
115-
const std::unordered_set<int>& blacklisted_ops,
115+
const std::unordered_set<int>& blocklisted_ops,
116116
onnxBackendID backend_id) const;
117117

118118
// Tie the output of Gather to the scalar weight input of the
@@ -123,20 +123,20 @@ class CAFFE2_API OnnxifiTransformer final : public BackendTransformerBase {
123123
const NetDef& net,
124124
const ShapeInfoMap& shape_hints,
125125
const std::unordered_set<std::string>& weights,
126-
std::unordered_set<int>* blacklisted_ops) const;
126+
std::unordered_set<int>* blocklisted_ops) const;
127127

128-
// For net with partitioning info, blacklist ops that are supposed to run on
128+
// For net with partitioning info, blocklist ops that are supposed to run on
129129
// CPU, whose partition info will contain empty device_id list.
130-
void blacklistCpuPartition(
130+
void blocklistCpuPartition(
131131
const NetDef& net,
132-
std::unordered_set<int>* blacklisted_ops) const;
132+
std::unordered_set<int>* blocklisted_ops) const;
133133

134134
// Rule based filtering
135135
void applyFilteringRules(
136136
const NetDef& net,
137137
const ShapeInfoMap& shape_hints,
138138
const std::unordered_set<std::string>& weights,
139-
std::unordered_set<int>* blacklisted_ops) const;
139+
std::unordered_set<int>* blocklisted_ops) const;
140140

141141
// Determine backend id
142142
void getBackendId();

0 commit comments

Comments
 (0)