From 137b7d0276859582b8ab43f9a20446b1a4e165e9 Mon Sep 17 00:00:00 2001 From: Serge Panev Date: Tue, 14 Jul 2020 10:17:36 -0700 Subject: [PATCH] Address PR comments Signed-off-by: Serge Panev --- include/mxnet/c_api.h | 19 +++++++++++ src/common/exec_utils.h | 72 ----------------------------------------- 2 files changed, 19 insertions(+), 72 deletions(-) diff --git a/include/mxnet/c_api.h b/include/mxnet/c_api.h index 79c2d6f74ddd..36c76e5a3c57 100644 --- a/include/mxnet/c_api.h +++ b/include/mxnet/c_api.h @@ -2235,6 +2235,25 @@ MXNET_DLL int MXGenAtomicSymbolFromSymbol(SymbolHandle sym_handle, SymbolHandle * \param num_options number of key value pairs * \param keys keys for options * \param vals values corresponding to keys + * \param num_input_shapes number of input shapes + * \param input_shape_names names of the input shapes + * \param input_shape_data pointer to the contiguous data shapes + * \param input_shape_idx array of per shape starting idx, the shape length for the i-th input shape + * is calculate as input_shape_idx[i+1] - input_shape_idx[i] + * \param num_input_dtypes number of input data types + * \param input_dtype_names array of names of the input data types + * \param input_dtypes array of values of the input data types + * \param num_input_stypesnumber of input storage types + * \param input_stype_names array of names of the input storage types + * \param input_stypes array of values of input storage types + * \param skip_infer if the optimization should skip the attribute inferences + * (to use if the backend does not require shape inference) + * \param new_args_cnt pointer a number to store the number of new args + * \param new_args_handle pointer on array to store the new args handles + * \param new_arg_names_handle pointer on array to store the new args names + * \param new_aux_cnt pointer a number to store the number of new aux + * \param new_aux_handle pointer on array to store the new aux handles + * \param new_aux_names_handle pointer on array to store the new aux names */ MXNET_DLL int MXOptimizeForBackend(SymbolHandle sym_handle, const char* backend_name, diff --git a/src/common/exec_utils.h b/src/common/exec_utils.h index ff1c477990e5..d69e0c555fd5 100644 --- a/src/common/exec_utils.h +++ b/src/common/exec_utils.h @@ -369,78 +369,6 @@ inline void LogInferStorage(const nnvm::Graph& g) { } } -// prints a helpful message after shape inference errors in executor. -inline void HandleInferShapeError(const size_t num_forward_inputs, - const nnvm::IndexedGraph& idx, - const mxnet::ShapeVector& inferred_shapes) { - int cnt = 10; - std::ostringstream oss; - for (size_t i = 0; i < num_forward_inputs; ++i) { - const uint32_t nid = idx.input_nodes().at(i); - const uint32_t eid = idx.entry_id(nid, 0); - const mxnet::TShape& inferred_shape = inferred_shapes[eid]; - if (!shape_is_known(inferred_shape)) { - const std::string& arg_name = idx[nid].source->attrs.name; - oss << arg_name << ": " << inferred_shape << ", "; - if (--cnt == 0) { - oss << "..."; - break; - } - } - } - LOG(FATAL) << "InferShape pass cannot decide shapes for the following arguments " - "(-1 means unknown dimensions). Please consider providing them as inputs:\n" - << oss.str(); -} - -// prints a helpful message after type inference errors in executor. -inline void HandleInferTypeError(const size_t num_forward_inputs, - const nnvm::IndexedGraph& idx, - const nnvm::DTypeVector& inferred_dtypes) { - int cnt = 10; - std::ostringstream oss; - for (size_t i = 0; i < num_forward_inputs; ++i) { - const uint32_t nid = idx.input_nodes().at(i); - const uint32_t eid = idx.entry_id(nid, 0); - const int inferred_dtype = inferred_dtypes[eid]; - if (inferred_dtype == -1) { - const std::string& arg_name = idx[nid].source->attrs.name; - oss << arg_name << ": " << inferred_dtype << ", "; - if (--cnt == 0) { - oss << "..."; - break; - } - } - } - LOG(FATAL) << "InferType pass cannot decide dtypes for the following arguments " - "(-1 means unknown dtype). Please consider providing them as inputs:\n" - << oss.str(); -} - -// prints a helpful message after storage type checking errors in executor. -inline void HandleInferStorageTypeError(const size_t num_forward_inputs, - const nnvm::IndexedGraph& idx, - const StorageTypeVector& inferred_stypes) { - int cnt = 10; - std::ostringstream oss; - for (size_t i = 0; i < num_forward_inputs; ++i) { - const uint32_t nid = idx.input_nodes().at(i); - const uint32_t eid = idx.entry_id(nid, 0); - const int inferred_stype = inferred_stypes[eid]; - if (inferred_stype == -1) { - const std::string& arg_name = idx[nid].source->attrs.name; - oss << arg_name << ": " << common::stype_string(inferred_stype) << ", "; - if (--cnt == 0) { - oss << "..."; - break; - } - } - } - LOG(FATAL) << "InferStorageType pass cannot decide storage type for the following arguments " - "(-1 means unknown stype). Please consider providing them as inputs:\n" - << oss.str(); -} - /*! * \brief If the requested ndarray's shape size is less than * the corresponding shared_data_array's shape size and the