flashlight / flashlight

A C++ standalone library for machine learning
https://fl.readthedocs.io/en/latest/
MIT License
5.2k stars 498 forks source link

Using SequentialBuilder without an arch file #498

Open lunixbochs opened 3 years ago

lunixbochs commented 3 years ago

Feature Description

It would be nice to pass a vector of strings directly to a buildSequentialModule() variant, as this saves writing a temporary file to disk if my program came up with the arch definition another way.

Additional Context

Here's a possible implementation: https://github.com/talonvoice/flashlight/commit/766f2fd847e7b83aedd69212a228007607ce768d

tlikhomanenko commented 3 years ago

We are planing to remove arch file at all and switch to plugins. What do you think about it?

lunixbochs commented 3 years ago

Hmm I like the arch layer lines, it would be much more annoying if I had to implement the whole sequentialbuilder logic myself, or recompile a shared library every time I modify an arch.

tlikhomanenko commented 3 years ago

The problem now is that for example transformer forward should need to have extra param for forward like mask and if you do crazy stuff with resnet block with transformer inside this will not work anyway. Example of model definition with plugin looks like this https://github.com/facebookresearch/flashlight/blob/master/flashlight/app/lm/plugins/LmAdae512SinposL8H8Fc1024Dp03Ldp0Adsm.cpp (similar to pytorch/tensorflow style anyway).