Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 2610c10

Browse files
authored
Change Partition API's options_map to std::unordered_map (#18929)
Signed-off-by: Serge Panev <spanev@nvidia.com>
1 parent be12c8d commit 2610c10

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

src/c_api/c_api.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <mutex>
2929
#include <memory>
3030
#include <functional>
31+
#include <unordered_map>
3132
#include <utility>
3233
#include "dmlc/base.h"
3334
#include "dmlc/logging.h"
@@ -1263,8 +1264,8 @@ void registerPasses(void *lib, int verbose, mxnet::ext::msgSize_t msgSize,
12631264
// get pass name
12641265
const char* pass_name = g.GetAttr<const char*>("pass_name");
12651266
// get options
1266-
const std::vector<std::pair<std::string, std::string>>& options_map =
1267-
g.GetAttr<const std::vector<std::pair<std::string, std::string>>>("options_map");
1267+
const std::unordered_map<std::string, std::string>& options_map =
1268+
g.GetAttr<const std::unordered_map<std::string, std::string>>("options_map");
12681269
// convert options_map_ to char* to pass to backend library
12691270
std::vector<const char*> opt_keys, opt_vals;
12701271
for (auto& kv : options_map) {

src/c_api/c_api_symbolic.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,9 +1504,9 @@ int MXOptimizeForBackend(SymbolHandle sym_handle,
15041504
g.attrs["in_aux_names"] = std::make_shared<nnvm::any>(aux_names);
15051505
}
15061506
// create a data structure from pointer array
1507-
std::vector<std::pair<std::string, std::string>> options_map;
1507+
std::unordered_map<std::string, std::string> options_map;
15081508
for (mx_uint i = 0; i < num_options; ++i)
1509-
options_map.emplace_back(keys[i], vals[i]);
1509+
options_map.emplace(keys[i], vals[i]);
15101510

15111511
if (mxnet::op::SubgraphBackendRegistry::Get()->backend_map_.count(backend_name) > 0) {
15121512
// use subgraph backend

src/operator/subgraph/partitioner/custom_subgraph_property.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class CustomSubgraphProperty: public SubgraphProperty {
189189
}
190190

191191
void PrePartition(const nnvm::Graph& g,
192-
const std::vector<std::pair<std::string, std::string>>& options_map) {
192+
const std::unordered_map<std::string, std::string>& options_map) {
193193
// clear supported_nodes to remove state from previous calls
194194
supported_nodes.clear();
195195
// get input args and arg names

src/operator/subgraph/subgraph_property.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class SubgraphProperty {
269269
}
270270

271271
virtual void PrePartition(const nnvm::Graph& g,
272-
const std::vector<std::pair<std::string, std::string>>& options_map) {}
272+
const std::unordered_map<std::string, std::string>& options_map) {}
273273

274274
virtual void PostPartition(const nnvm::Graph& g) {}
275275

src/operator/subgraph/tensorrt/tensorrt-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class TensorrtProperty : public SubgraphProperty {
268268
}
269269

270270
void PrePartition(const nnvm::Graph& g,
271-
const std::vector<std::pair<std::string, std::string>>& options_map) override {
271+
const std::unordered_map<std::string, std::string>& options_map) override {
272272
auto& in_arg_names = g.GetAttr<std::vector<std::string>>("in_arg_names");
273273
auto& in_aux_names = g.GetAttr<std::vector<std::string>>("in_aux_names");
274274
NDArray **in_args_ptr = g.GetAttr<NDArray**>("in_args");

0 commit comments

Comments
 (0)