This is an automated email from the ASF dual-hosted git repository.
zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 2610c10 Change Partition API's options_map to std::unordered_map
(#18929)
2610c10 is described below
commit 2610c10701c2b8155dbf094aaecba37ebbf67d0f
Author: Serge Panev <[email protected]>
AuthorDate: Sat Aug 15 19:30:50 2020 -0700
Change Partition API's options_map to std::unordered_map (#18929)
Signed-off-by: Serge Panev <[email protected]>
---
src/c_api/c_api.cc | 5 +++--
src/c_api/c_api_symbolic.cc | 4 ++--
src/operator/subgraph/partitioner/custom_subgraph_property.h | 2 +-
src/operator/subgraph/subgraph_property.h | 2 +-
src/operator/subgraph/tensorrt/tensorrt-inl.h | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc
index 1e78eac..23049f1 100644
--- a/src/c_api/c_api.cc
+++ b/src/c_api/c_api.cc
@@ -28,6 +28,7 @@
#include <mutex>
#include <memory>
#include <functional>
+#include <unordered_map>
#include <utility>
#include "dmlc/base.h"
#include "dmlc/logging.h"
@@ -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) {
diff --git a/src/c_api/c_api_symbolic.cc b/src/c_api/c_api_symbolic.cc
index 06f956b..caee762 100644
--- a/src/c_api/c_api_symbolic.cc
+++ b/src/c_api/c_api_symbolic.cc
@@ -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
diff --git a/src/operator/subgraph/partitioner/custom_subgraph_property.h
b/src/operator/subgraph/partitioner/custom_subgraph_property.h
index b936b05..f2d715b 100644
--- a/src/operator/subgraph/partitioner/custom_subgraph_property.h
+++ b/src/operator/subgraph/partitioner/custom_subgraph_property.h
@@ -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
diff --git a/src/operator/subgraph/subgraph_property.h
b/src/operator/subgraph/subgraph_property.h
index 5e87626..7fadfca 100644
--- a/src/operator/subgraph/subgraph_property.h
+++ b/src/operator/subgraph/subgraph_property.h
@@ -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) {}
diff --git a/src/operator/subgraph/tensorrt/tensorrt-inl.h
b/src/operator/subgraph/tensorrt/tensorrt-inl.h
index 3119d31..79e3d82 100644
--- a/src/operator/subgraph/tensorrt/tensorrt-inl.h
+++ b/src/operator/subgraph/tensorrt/tensorrt-inl.h
@@ -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");