Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata #26

Open
joaoleal opened this Issue Jan 22, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@joaoleal
Copy link

joaoleal commented Jan 22, 2018

Hello Brad,

Is there a chance of CppAD supporting metadata associated with each variable.
One could call something like

AD<type> var = (...);
add_metadata(var, "key", "value");

This information could then be used to store information such as variable names and units.
An additional call to new functions (e.g., process_metadata_forward() and process_metadata_reverse()) could be added in
cppad/local/forward0sweep.hpp
cppad/local/forward1sweep.hpp
cppad/local/forward2sweep.hpp
cppad/local/reverse_sweep.hpp

By default process_metadata_*() functions would be empty (no performance penalty would occur for types such as double/float).
These functions could be specialized for specific data types such as CppAD::cg::CG<>.

This would allow me to recover the additional information that I need which cannot currently be saved in the tape.

Best regards,
João Leal

@bradbell

This comment has been minimized.

Copy link
Contributor

bradbell commented Aug 23, 2018

As I understand, you would like the meta data stored in the tape ?

I have thought of putting source code file and line numbers in the tape, detecting infinities and nans, and then reporting the corresponding source code.

You have a different use for the extra information in the tape, and I should understand it.

Perhaps the right way to do it is to add yet another argument to the Independent function that signals more information about the recording; see
https://coin-or.github.io/CppAD/doc/independent.htm

@joaoleal

This comment has been minimized.

Copy link
Author

joaoleal commented Aug 25, 2018

At the moment I do need that feature anymore (I'm in different company now).
However, it could still be useful for cppad.
The idea was to associate each variable with additional information such as a variable name and units.
Perhaps there could be a function to associate additional information with a variable during the taping process.
It looks like a very similar feature to saving the line numbers.
Instead of integers for the line number, it would be strings (or pairs of strings) provided by the user.

@bradbell

This comment has been minimized.

Copy link
Contributor

bradbell commented Aug 25, 2018

Does the base class object know the information when to operation is recorded. Perhaps it would be possible to extend the base class specifications to include a template function that has a default definition that is empty and that the compiler can know is empty.

@joaoleal

This comment has been minimized.

Copy link
Author

joaoleal commented Aug 26, 2018

The variable name/units is known at the moment the operation is performed during the taping process.
There could be some default inline functions that do nothing by default but that could be specialized to register additional information when CppAD records the operation and then use that information later on when the tape is played.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.