Update the interface for the layer.h setProperty.
Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
l = nnlayer->layer;
}
- returnable f = [&]() { return l->setProperty(arg_list); };
+ returnable f = [&]() {
+ l->setProperty(arg_list);
+ return ML_ERROR_NONE;
+ };
status = nntrainer_exception_boundary(f);
return status;
* @details This function accepts vector of properties in the format -
* { std::string property_name, void * property_val, ...}
*/
- virtual int setProperty(std::vector<std::string> values) = 0;
+ virtual void setProperty(const std::vector<std::string> &values) = 0;
/**
* @brief Get name of the layer
std::unique_ptr<Layer> createLayer(const std::vector<std::string> &props = {}) {
std::unique_ptr<Layer> ptr = std::make_unique<T>();
- if (ptr->setProperty(props) != ML_ERROR_NONE) {
- throw std::invalid_argument("Set properties failed for layer");
- }
+ ptr->setProperty(props);
return ptr;
}
$(NNTRAINER_ROOT)/nntrainer/layers/layer_impl.cpp \
$(NNTRAINER_ROOT)/nntrainer/graph/network_graph.cpp \
$(NNTRAINER_ROOT)/nntrainer/graph/graph_core.cpp \
+ $(NNTRAINER_ROOT)/nntrainer/optimizers/optimizer_context.cpp \
$(NNTRAINER_ROOT)/nntrainer/optimizers/optimizer_devel.cpp \
$(NNTRAINER_ROOT)/nntrainer/optimizers/optimizer_impl.cpp \
$(NNTRAINER_ROOT)/nntrainer/optimizers/adam.cpp \
* @note name of each node in the graph must be unique, and caller must ensure
* that
*/
- virtual int setName(const std::string &name) = 0;
+ virtual void setName(const std::string &name) = 0;
/**
* @brief Get the Type of the underlying object
createLayerNode(std::unique_ptr<nntrainer::Layer> &&layer,
const std::vector<std::string> &properties) {
auto lnode = std::make_unique<LayerNode>(std::move(layer));
- if (lnode->setProperty(properties) != ML_ERROR_NONE)
- throw std::invalid_argument("Error setting layer properties.");
+ lnode->setProperty(properties);
return lnode;
}
}
}
-int LayerNode::setProperty(std::vector<std::string> properties) {
- int status = ML_ERROR_NONE;
+void LayerNode::setProperty(const std::vector<std::string> &properties) {
bool already_distributed =
!std::get<props::Distribute>(*layer_node_props).empty() &&
std::get<props::Distribute>(*layer_node_props).get();
std::string key;
std::string value;
+ std::stringstream ss;
- status = getKeyValue(left_properties[i], key, value);
- NN_RETURN_STATUS();
+ if (getKeyValue(left_properties[i], key, value) != ML_ERROR_NONE) {
+ throw std::invalid_argument("Error parsing the property: " +
+ left_properties[i]);
+ }
if (value.empty()) {
- ml_logd("value is empty for layer: %s, key: %s, value: %s",
- getName().c_str(), key.c_str(), value.c_str());
- return ML_ERROR_INVALID_PARAMETER;
+ ss << "value is empty: key: " << key << ", value: " << value;
+ throw std::invalid_argument(ss.str());
}
/// @note this calls derived setProperty if available
}
layer->setProperty(remainder);
-
- return status;
}
bool LayerNode::setProperty(const std::string &key, const std::string &value) {
* @details This function accepts vector of properties in the format -
* { std::string property_name=property_val, ...}
*
- * @todo update to new signature: void setProperty(const
- * std::vector<std::string> &values)
*/
- int setProperty(std::vector<std::string> properties) override;
+ void setProperty(const std::vector<std::string> &properties) override;
/**
* @brief Get name of the layer
* @brief set name of layer
*
* @param[in] name Name of the layer
- * @retval #ML_ERROR_NONE Successful.
- * @retval #ML_ERROR_INVALID_PARAMETER invalid parameter.
- *
- * @todo update to new signature void setName(const std::string &name)
*/
- int setName(const std::string &name) { return setProperty({"name=" + name}); }
+ void setName(const std::string &name) { setProperty({"name=" + name}); }
/**
* @brief Get the input connections for this node