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

Change Partition API's options_map to std::unordered_map #18929

Merged
merged 1 commit into from
Aug 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/c_api/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <mutex>
#include <memory>
#include <functional>
#include <unordered_map>
#include <utility>
#include "dmlc/base.h"
#include "dmlc/logging.h"
Expand Down Expand Up @@ -1263,8 +1264,8 @@ void registerPasses(void *lib, int verbose, mxnet::ext::msgSize_t msgSize,
// get pass name
const char* pass_name = g.GetAttr<const char*>("pass_name");
// get options
const std::vector<std::pair<std::string, std::string>>& options_map =
g.GetAttr<const std::vector<std::pair<std::string, std::string>>>("options_map");
const std::unordered_map<std::string, std::string>& options_map =
g.GetAttr<const std::unordered_map<std::string, std::string>>("options_map");
// convert options_map_ to char* to pass to backend library
std::vector<const char*> opt_keys, opt_vals;
for (auto& kv : options_map) {
Expand Down
4 changes: 2 additions & 2 deletions src/c_api/c_api_symbolic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1504,9 +1504,9 @@ int MXOptimizeForBackend(SymbolHandle sym_handle,
g.attrs["in_aux_names"] = std::make_shared<nnvm::any>(aux_names);
}
// create a data structure from pointer array
std::vector<std::pair<std::string, std::string>> options_map;
std::unordered_map<std::string, std::string> options_map;
for (mx_uint i = 0; i < num_options; ++i)
options_map.emplace_back(keys[i], vals[i]);
options_map.emplace(keys[i], vals[i]);

if (mxnet::op::SubgraphBackendRegistry::Get()->backend_map_.count(backend_name) > 0) {
// use subgraph backend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class CustomSubgraphProperty: public SubgraphProperty {
}

void PrePartition(const nnvm::Graph& g,
const std::vector<std::pair<std::string, std::string>>& options_map) {
const std::unordered_map<std::string, std::string>& options_map) {
// clear supported_nodes to remove state from previous calls
supported_nodes.clear();
// get input args and arg names
Expand Down
2 changes: 1 addition & 1 deletion src/operator/subgraph/subgraph_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class SubgraphProperty {
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/operator/subgraph/tensorrt/tensorrt-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class TensorrtProperty : public SubgraphProperty {
}

void PrePartition(const nnvm::Graph& g,
const std::vector<std::pair<std::string, std::string>>& options_map) override {
const std::unordered_map<std::string, std::string>& options_map) override {
auto& in_arg_names = g.GetAttr<std::vector<std::string>>("in_arg_names");
auto& in_aux_names = g.GetAttr<std::vector<std::string>>("in_aux_names");
NDArray **in_args_ptr = g.GetAttr<NDArray**>("in_args");
Expand Down