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

Closed
joaoleal opened this issue Jan 22, 2018 · 5 comments
Closed

Metadata #26

joaoleal opened this issue Jan 22, 2018 · 5 comments

Comments

@joaoleal
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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.

@bradbell
Copy link
Contributor

bradbell commented Jan 3, 2021

I am moving this issue to discussion #84

@bradbell bradbell closed this as completed Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants