nntrainer
nntrainer copied to clipboard
Make layer plugin directly work with ml api.
layer plugin developer has some burden to create and use the layer right away.
let's assume there is a custom layer
class MyLayer : public nntrainer::Layer {
/** define interfaces */
};
With this, below code is not only invalid, but will compile and segfault, because we have defined (implicitly) that only layerNode is a valid layer. not nntrainer::Layer.
int main() {
auto model = ml::train::createModel();
auto my_layer = std::make_shared<ml::train::Layer>(new MyLayer);
model->addLayer(my_layer);
}
option 1. we make above code valid. ( = make nntrainer::layerNode
not type of ml::train::Layer
)
Pass only layer not layerNode between codes while layerNode is only available inside NeuralNetworks
option 2. we make below code valid. ( = make nntrainer::Layer
not type of ml::train::Layer
)
int main() {
auto model = ml::train::createModel();
auto my_layer = std::make_shared<ml::train::Layer>(new MyLayer);
auto ML_API_layer = ml::train::createCustomLayer(my_layer);
model->addLayer(ML_API_layer);
}
opinion
option 2 will need api change, option 1. need massive changes, although I think option 1. is more appropriate.
:octocat: cibot: Thank you for posting issue #1751. The person in charge will reply soon.
It turned out that we are already at option 2. but we lack of API to create LayerNode from plain layer, we will need to support this.