}
std::vector<TensorDim> NetworkGraph::getInputDimension() const {
- NNTR_THROW_IF(this->empty(), std::invalid_argument)
- << "[NetworkGraph] the graph has no node!";
- return getSortedLayerNode(0)->getInputDimensions();
+ NNTR_THROW_IF(input_dims.empty(), std::invalid_argument)
+ << "[NetworkGraph] the graph has no node identified as input!";
+ return input_dims;
}
unsigned int NetworkGraph::getBatchSize() const { return batch_size; }
std::vector<TensorDim> NetworkGraph::getOutputDimension() const {
- NNTR_THROW_IF(this->empty(), std::invalid_argument)
- << "[NetworkGraph] the graph has no node!";
- return getSortedLayerNode(graph.size() - 1)->getOutputDimensions();
+ NNTR_THROW_IF(label_dims.empty(), std::invalid_argument)
+ << "[NetworkGraph] the graph has no node identified as output!";
+ /// for now, outputting label_dims works, later label dim will be different
+ /// from output dimension
+ return label_dims;
}
std::vector<std::shared_ptr<LayerNode>>
<< num_input;
input_list.push_back(node->getInput(0).getName());
+ input_dims.push_back(node->getInputDimensions()[0]);
};
auto is_label_node = [](LayerNode *node) { return node->requireLabel(); };
<< num_label;
label_list.push_back(node->getOutputGrad(0).getName());
+ label_dims.push_back(node->getOutputDimensions()[0]);
};
auto identify_external_tensors = [this](const std::vector<std::string> &names,
* @brief Swap function for the class
*/
friend void swap(NetworkGraph &lhs, NetworkGraph &rhs) {
+ /// @fixme this swap function need maintenance
using std::swap;
swap(lhs.graph, rhs.graph);
unsigned int batch_size; /**< current batch_size */
// std::vector<Var_Grad *> label_list; /**< var_grads for the labels */
// std::vector<Var_Grad *> input_list; /**< var_grads for the inputs */
- std::vector<std::string> label_list; /**< var_grads for the labels */
- std::vector<std::string> input_list; /**< var_grads for the inputs */
+ std::vector<std::string> label_list; /**< identifier for the model labels */
+ std::vector<std::string> input_list; /**< identifier for the model inputs */
+ std::vector<TensorDim> label_dims; /**< graph label dimensions */
+ std::vector<TensorDim> input_dims; /**< graph input dimensions */
+
ExecutionMode exec_mode; /**< execution mode with which the graph has been
currently set or previously set */