strange syntax
Ariesnl

I was helping a collegue with tensor flow and I came across this syntax...

I've never seen this in C++

InterpreterBuilder(*pModel, resolver)(&pInterpreter);

where pModel is a pointer and strangely enough pInterpreter is a pointer too so in that case the address of a pointer is passed ??? that would be a pointer pointer which makes no sense in this case....

anyone ?

Erin Maus

It looks like InterpreterBuilder is a class that overloads the function call operator: https://en.cppreference.com/w/cpp/language/operators

So you're calling the constructor then calling the overload. Or it could be a function that returns an object that overloads the function call operator but that seems less likely.

I've never used Tensorflow so I don't know for certain but those are two possible explanations for that syntax.

Peter Hull

It's this:
https://www.tensorflow.org/lite/api_docs/cc/class/tflite/interpreter-builder

The code is doing something like

std::unique_ptr<Interpreter>* pInterpreter= ...;
FlatBuffer* pModel = ...;
OpResolver resolver = ...;
InterpreterBuilder builder(*pModel, resolver); // construct
TfLiteStatus status = builder(&pInterpreter); // call operator()

and the last line is really

TfLiteStatus status = builder.operator()(&pInterpreter);

Thread #618068. Printed from Allegro.cc