Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion NeoML/include/NeoML/Dnn/Dnn.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ class NEOML_API CBaseLayer : public virtual IObject {
//
// e.g. layer "InputHidden" inside of CLstmLayer named "LSTM", which is inside of CCompositeLayer named "Encoder"
// has path "Encoder/LSTM/InputHidden"
CString GetPath() const;
CString GetPath( const char* sep = "/" ) const;
// Path in form suitable for dnn->GetLayer( CArray<CString>& path );
// Returns an empty array if the path cannot be constructed.
void GetPath( CArray<CString>& path ) const;

// Connects this layer's inputNumber input to the specified layer's outputNumber output
virtual void Connect( int inputNumber, const char* layer, int outputNumber = 0 );
Expand Down Expand Up @@ -388,6 +391,8 @@ class NEOML_API CBaseLayer : public virtual IObject {
// Indicates if the layer performs in-place processing (after the Reshape method call)
bool isInPlace;

// Technical method for recursion in GetPath( CArray<CString>& path )
void getPath( CArray<CString>& path ) const;
// Switches the specified blobs into sequence processing mode
void switchBlobsToSequentialMode(CObjectArray<CDnnBlob>& blobs, TBlobCacheType cacheType, bool storeParent);
void switchBlobsToNonSequentialMode(CObjectArray<CDnnBlob>& blobs, TBlobCacheType cacheType, bool clear);
Expand Down
23 changes: 20 additions & 3 deletions NeoML/include/NeoML/Dnn/Dnn.inl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2023 ABBYY
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,9 +56,26 @@ inline bool CBaseLayer::IsBackwardNeeded() const
return isBackwardNeeded == BS_NeedsBackward;
}

inline CString CBaseLayer::GetPath() const
inline CString CBaseLayer::GetPath( const char* sep ) const
{
return dnn == nullptr || dnn->owner == nullptr ? name : dnn->owner->GetPath() + "/" + name;
return ( dnn == nullptr || dnn->owner == nullptr ) ? name : ( dnn->owner->GetPath( sep ) + sep + name );
}

inline void CBaseLayer::GetPath( CArray<CString>& path ) const
{
path.DeleteAll();
getPath( path );
}

inline void CBaseLayer::getPath( CArray<CString>& path ) const
{
if( dnn == nullptr ) {
return;
}
if( dnn->owner != nullptr ) {
dnn->owner->getPath( path );
}
path.Add( name );
}

inline void CBaseLayer::CheckLayerArchitecture( bool expr, const char* message ) const
Expand Down
Loading