diff --git a/include/codi/tapes/jacobianBaseTape.hpp b/include/codi/tapes/jacobianBaseTape.hpp index 53a440fb..54a56baa 100644 --- a/include/codi/tapes/jacobianBaseTape.hpp +++ b/include/codi/tapes/jacobianBaseTape.hpp @@ -241,12 +241,16 @@ namespace codi { checkAdjointSize(identifier); } + codiAssert(identifier < (Identifier)adjoints.size()); + return adjoints[identifier]; } /// \copydoc codi::GradientAccessTapeInterface::gradient(Identifier const&, AdjointsManagement) const CODI_INLINE Gradient const& gradient( Identifier const& identifier, AdjointsManagement adjointsManagement = AdjointsManagement::Automatic) const { + codiAssert(identifier < (Identifier)adjoints.size()); + if (AdjointsManagement::Automatic == adjointsManagement && identifier >= (Identifier)adjoints.size()) { return adjoints[0]; } else { @@ -730,6 +734,8 @@ namespace codi { adjoints.beginUse(); } + codiAssert(indexManager.get().getLargestCreatedIndex() < (Identifier)adjoints.size()); + cast().evaluateForward(start, end, adjoints.data()); if (AdjointsManagement::Automatic == adjointsManagement) { @@ -794,6 +800,8 @@ namespace codi { adjoints.beginUse(); } + codiAssert(indexManager.get().getLargestCreatedIndex() < (Identifier)adjoints.size()); + evaluate(start, end, adjoints.data()); if (AdjointsManagement::Automatic == adjointsManagement) { diff --git a/include/codi/tapes/primalValueBaseTape.hpp b/include/codi/tapes/primalValueBaseTape.hpp index 0320c2d7..ada934ae 100644 --- a/include/codi/tapes/primalValueBaseTape.hpp +++ b/include/codi/tapes/primalValueBaseTape.hpp @@ -274,6 +274,8 @@ namespace codi { checkAdjointSize(identifier); } + codiAssert(identifier < (Identifier)adjoints.size()); + return adjoints[identifier]; } @@ -282,6 +284,8 @@ namespace codi { /// implement adjoints locking. CODI_INLINE Gradient const& gradient( Identifier const& identifier, AdjointsManagement adjointsManagement = AdjointsManagement::Automatic) const { + codiAssert(identifier < (Identifier)adjoints.size()); + if (AdjointsManagement::Automatic == adjointsManagement && identifier >= (Identifier)adjoints.size()) { return adjoints[0]; } else { @@ -875,6 +879,8 @@ namespace codi { checkAdjointSize(indexManager.get().getLargestCreatedIndex()); } + codiAssert(indexManager.get().getLargestCreatedIndex() < (Identifier)adjoints.size()); + cast().evaluateForward(start, end, adjoints.data()); } @@ -1068,6 +1074,8 @@ namespace codi { checkAdjointSize(indexManager.get().getLargestCreatedIndex()); } + codiAssert(indexManager.get().getLargestCreatedIndex() < (Identifier)adjoints.size()); + evaluate(start, end, adjoints.data()); } @@ -1095,6 +1103,8 @@ namespace codi { checkAdjointSize(indexManager.get().getLargestCreatedIndex()); } + codiAssert(indexManager.get().getLargestCreatedIndex() < (Identifier)adjoints.size()); + internalEvaluateReverse(start, end, adjoints.data()); if (!TapeTypes::IsLinearIndexHandler) { @@ -1111,6 +1121,8 @@ namespace codi { checkAdjointSize(indexManager.get().getLargestCreatedIndex()); } + codiAssert(indexManager.get().getLargestCreatedIndex() < (Identifier)adjoints.size()); + if (!TapeTypes::IsLinearIndexHandler) { cast().internalResetPrimalValues(end); }