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

Fixed bug in node in command-line ONNX parser #858

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next Release
- Adding incremental infrastructure which allows pushing and popping constraints to/from the InputQuery.
- Dropped support for parsing Tensorflow network format. Newest Marabou version that supports Tensorflow is at commit 190555573e4702.
- Fixed bug in the parsing of `transpose` nodes in command line C++ parser.

## Version 2.0.0

Expand Down
2 changes: 1 addition & 1 deletion src/input_parsers/TensorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ calculatePaddingNeeded( int inputSize, int filterSize, int stride, bool padFront
Permutation reversePermutation( unsigned int size )
{
Permutation result;
for ( unsigned int i = size - 1; i-- > 0; )
for ( unsigned int i = size; i-- > 0; )
{
result.append( i );
}
Expand Down
16 changes: 9 additions & 7 deletions src/input_parsers/TensorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ TensorIndices unpackIndex( TensorShape shape, PackedTensorIndices packedIndex );

PackedTensorIndices packIndex( TensorShape shape, TensorIndices indices );

unsigned int tensorSize( TensorShape shape );

template <typename T> T tensorLookup( Vector<T> tensor, TensorShape shape, TensorIndices indices )
{
return tensor[packIndex( shape, indices )];
Expand All @@ -77,20 +79,20 @@ Vector<T> transposeTensor( Vector<T> tensor, TensorShape shape, Permutation perm
// NOTE this implementation is *very* inefficient. Eventually we might want to
// switch to a similar implementation as NumPy arrays with internal strides etc.
ASSERT( shape.size() == permutation.size() );
ASSERT( tensorSize( shape ) == tensor.size() );

TensorShape transposedShape = transposeVector( shape, permutation );
Vector<T> result( tensor.size() );
for ( PackedTensorIndices rawOutputIndex = 0; rawOutputIndex < tensor.size(); rawOutputIndex++ )
for ( PackedTensorIndices rawInputIndex = 0; rawInputIndex < tensor.size(); rawInputIndex++ )
{
TensorIndices outputIndex = unpackIndex( transposedShape, rawOutputIndex );
TensorIndices inputIndex = transposeVector( outputIndex, permutation );
T value = tensorLookup( tensor, shape, inputIndex );
result[rawOutputIndex] = value;
TensorIndices inputIndex = unpackIndex( shape, rawInputIndex );
TensorIndices outputIndex = transposeVector( inputIndex, permutation );
int rawOutputIndex = packIndex( transposedShape, outputIndex );
result[rawOutputIndex] = tensor[rawInputIndex];
}
return result;
}

unsigned int tensorSize( TensorShape shape );

// See https://github.com/onnx/onnx/blob/main/docs/Broadcasting.md#multidirectional-broadcasting
TensorShape getMultidirectionalBroadcastShape( TensorShape shape1, TensorShape shape2 );

Expand Down
Loading