Tensorflow dll

Questions about MultiCharts and user contributed studies.
User avatar
Smoky
Posts: 518
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 99 times
Been thanked: 121 times

Tensorflow dll

Postby Smoky » 03 Apr 2024

i made a Tensorflow dll to make prediction with Multicharts. Everything is working well when i call the dll from C++ application.

but with MC when i return a pointer to the model i got a memory popup error.

here my loading model in c++

Code: Select all

// LOAD NN engine with CPPFLOW //return model ID for futur call //engine filename is on dll folder std::unique_ptr< cppflow::model> __stdcall BinaCpp_loadNN( char* filename) { //loading the model each time causes overload. //Either you load the model in global scope (outside of any class or main). //The other option is to create a unique pointer which will be loaded once when first called. //Declare unique pointer: auto model = std::make_unique<cppflow::model>(std::string(filename)); return model; }
my MC code

Code: Select all

// DLL NAME RETURN VALUE FUNCTION NAME INPUTS DefineDLLFunc: "BinaApi.dll", int64, "BinaCpp_loadNN",LPSTR; // return int64 for pointer DefineDLLFunc: "BinaApi.dll", double, "BinaCpp_runNN",int,float,float; // return double int as pointer float as data inputs //saved engine files are in dll directory vars: intrabarpersist ModelID(0); vars: intrabarpersist prediction(0); vars: intrabarpersist varX(0), intrabarpersist varY(0), intrabarpersist loadNN(0); vars: heur(""),ret(0); Once begin //load the model in memory heur=LeftStr(FormatTime("HH:mm:ss:ms",datetime)+" ",14) ; messagelog(heur,"Load TF Model ... "); ModelID= BinaCpp_loadNN("C:\Program Files\TS Support\MultiCharts64"); heur=LeftStr(FormatTime("HH:mm:ss:ms",datetime)+" ",14) ; messagelog(heur,"Load ModelID ",ModelID); //never comming varX=1; varY=0; //setting inputs prediction = BinaCpp_runNN(ModelID,varx,vary); heur=LeftStr(FormatTime("HH:mm:ss:ms",datetime)+" ",14) ; messagelog(heur,"Prediction ",varx," ",varY," output = ",prediction); end;
any idea ?

User avatar
Smoky
Posts: 518
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 99 times
Been thanked: 121 times

Re: Tensorflow dll

Postby Smoky » 06 Apr 2024

Many thanks to Polly from the support team !


Return to “MultiCharts”