The interface is used by all the tape readers. The tape readers are used to restore a tape from either a text file or a binary file that was created by the codi::TapeWriterInterface. The readers produce an identical tape in a new context, which can be evaluated and new statements can be added. More...
#include <tapeReaderWriterInterface.hpp>
Public Member Functions | |
virtual std::vector< Identifier > const & | getInputs () const &=0 |
Used to get the restored inputs of the tape. | |
virtual std::vector< Identifier > const & | getOutputs () const &=0 |
virtual Tape & | getTape ()=0 |
Used to get a reference to the restored tape. | |
virtual void | readFile (std::string const &name) |
This method uses the the fileName to reproduce a valid tape. | |
virtual | ~TapeReaderInterface () |
Destructor. | |
The interface is used by all the tape readers. The tape readers are used to restore a tape from either a text file or a binary file that was created by the codi::TapeWriterInterface. The readers produce an identical tape in a new context, which can be evaluated and new statements can be added.
The readers are supported for both Jacobian and primal value tapes, however reading a primal value tape requires additional steps to restore the EvalHandles.
For reading and restoring a Jacobian tape file, the following steps are followed.
1) Use the codi::readTapeFile() with the name of the text or binary tape file that was previously created. Ensure that the file with the "IO.txt" or "IO.dat" suffix is also available in the same directory.
2) The restored tape can then be accessed using the codi::TapeReaderInterface::getTape() method.
3) Use the codi::TapeReaderInterface::getInputs() or codi::TapeReaderInterface::getOutputs() to set seed the gradients before evaluating the restored tape.
4) The same input and output vectors can be use to access the adjoint values after the evaluation.
The procedure for restoring a primal value tape is similar, however there is a header file "filename".hpp
that the codi::TapeWriterInterface produces, which needs to be added to reproduce the EvalHandles in the new context.
The example below shows the additional steps for a primal value tape
T_Type | The CoDiPack type of the tape that is to be restored. |
|
pure virtual |
Used to get the restored inputs of the tape.
Implemented in codi::CommonBaseTapeReader< T_Type >.
|
pure virtual |
Used to get the restored outputs of the tape.
Implemented in codi::CommonBaseTapeReader< T_Type >.
|
pure virtual |
Used to get a reference to the restored tape.
Implemented in codi::CommonBaseTapeReader< T_Type >.
|
inlinevirtual |
This method uses the the fileName to reproduce a valid tape.
Reimplemented in codi::JacobianBinaryTapeReader< T_Type >, codi::JacobianTextTapeReader< T_Type >, codi::PrimalBinaryTapeReader< T_Type >, and codi::PrimalTextTapeReader< T_Type >.