@ -74,6 +74,12 @@ static DDim GetDims(const Scope& scope, const std::string& name,
}
}
static bool VarInited ( const Scope & scope , const std : : string & name ) {
Variable * var = scope . FindVar ( name ) ;
if ( var = = nullptr ) return false ;
return var - > IsInitialized ( ) ;
}
static std : : string GetDtype ( const Scope & scope , const std : : string & name ) {
Variable * var = scope . FindVar ( name ) ;
if ( var = = nullptr ) {
@ -87,8 +93,12 @@ static std::string GetDtype(const Scope& scope, const std::string& name) {
}
return DataTypeToString ( ToDataType ( tensor . type ( ) ) ) ;
} else if ( var - > IsType < SelectedRows > ( ) ) {
return DataTypeToString (
ToDataType ( var - > Get < SelectedRows > ( ) . value ( ) . type ( ) ) ) ;
auto tensor = var - > Get < SelectedRows > ( ) . value ( ) ;
if ( UNLIKELY ( ! tensor . IsInitialized ( ) ) ) {
return " uninited " ;
} else {
return DataTypeToString ( ToDataType ( tensor . type ( ) ) ) ;
}
} else {
return " " ;
}
@ -197,16 +207,21 @@ std::string OperatorBase::DebugStringEx(const Scope* scope) const {
auto & input = * it ;
ss < < input . first < < " [ " ;
for ( size_t i = 0 ; i < input . second . size ( ) ; + + i ) {
ss < < input . second [ i ] ;
auto var_name = input . second [ i ] ;
ss < < var_name ;
if ( scope ) {
int row_size = GetRowSize ( * scope , input . second [ i ] ) ;
if ( ! VarInited ( * scope , var_name ) ) {
ss < < " [uninited] " ;
} else {
int row_size = GetRowSize ( * scope , var_name ) ;
if ( row_size > = 0 ) {
ss < < " [row_size= " < < row_size < < " ] " ;
}
std : : string dtype = GetDtype ( * scope , input. second [ i ] ) ;
std : : string dtype = GetDtype ( * scope , var_name ) ;
ss < < " : " < < dtype ;
ss < < " [ " < < GetDims ( * scope , input . second [ i ] , true ) < < " ] " ;
ss < < " ( " < < GetLoD ( * scope , input . second [ i ] ) < < " ) " ;
ss < < " [ " < < GetDims ( * scope , var_name , true ) < < " ] " ;
ss < < " ( " < < GetLoD ( * scope , var_name ) < < " ) " ;
}
}
if ( i ! = input . second . size ( ) - 1 ) {
ss < < " , " ;
@ -223,14 +238,19 @@ std::string OperatorBase::DebugStringEx(const Scope* scope) const {
auto & output = * it ;
ss < < output . first < < " [ " ;
for ( size_t i = 0 ; i < output . second . size ( ) ; + + i ) {
ss < < output . second [ i ] ;
auto var_name = output . second [ i ] ;
ss < < var_name ;
if ( scope ) {
if ( ! VarInited ( * scope , var_name ) ) {
ss < < " [uninited] " ;
} else {
int row_size = GetRowSize ( * scope , output . second [ i ] ) ;
if ( row_size > = 0 ) {
ss < < " [row_size= " < < row_size < < " ] " ;
}
ss < < " [ " < < GetDims ( * scope , output . second [ i ] , true ) < < " ] " ;
ss < < " ( " < < GetLoD ( * scope , output . second [ i ] ) < < " ) " ;
ss < < " [ " < < GetDims ( * scope , var_name , true ) < < " ] " ;
ss < < " ( " < < GetLoD ( * scope , var_name ) < < " ) " ;
}
}
if ( i ! = output . second . size ( ) - 1 ) {
ss < < " , " ;