Skip to content

Commit

Permalink
Merge pull request #31 from STEllAR-GROUP/quatslice_operation
Browse files Browse the repository at this point in the history
Adding quatslice view for 4D arrays
  • Loading branch information
hkaiser committed Jul 11, 2019
2 parents 0f4842a + 95c693e commit aee39d0
Show file tree
Hide file tree
Showing 75 changed files with 41,055 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Expand Up @@ -41,6 +41,8 @@ jobs:
# Run all tests
- run:
name: Run all the tests
environment:
CTEST_OUTPUT_ON_FAILURE: TRUE
command: cmake --build build --target test -- -j1

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion .clang-format
Expand Up @@ -44,7 +44,7 @@ BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: false
Expand Down
14 changes: 12 additions & 2 deletions CMakeLists.txt
Expand Up @@ -47,6 +47,9 @@ project(BlazeTensor
LANGUAGES CXX
VERSION "${BLAZE_TENSOR_MAJOR_VERSION}.${BLAZE_TENSOR_MINOR_VERSION}")

option(BLAZETENSOR_WITH_TESTS "Build BlazeTensor tests" OFF)
option(BLAZETENSOR_USE_HPX_THREADS "Use HPX thread backend" OFF)

# set minimally required C++ Standard
set(CMAKE_CXX_STANDARD 14)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down Expand Up @@ -81,10 +84,18 @@ target_link_libraries(BlazeTensor INTERFACE blaze::blaze)

# setup HPX, if needed
get_target_property(blaze_parallelization_mode blaze::blaze INTERFACE_COMPILE_DEFINITIONS)
if(blaze_parallelization_mode AND "${blaze_parallelization_mode}" STREQUAL "BLAZE_USE_HPX_THREADS")
if(
(blaze_parallelization_mode AND "${blaze_parallelization_mode}" STREQUAL "BLAZE_USE_HPX_THREADS")
OR BLAZETENSOR_USE_HPX_THREADS)

find_package(HPX REQUIRED NO_CMAKE_PACKAGE_REGISTRY)
target_include_directories(BlazeTensor INTERFACE ${HPX_INCLUDE_DIRS})
target_link_libraries(BlazeTensor INTERFACE ${HPX_LIBRARIES})

# Force using HPX
if(BLAZETENSOR_USE_HPX_THREADS)
add_compile_definitions(BLAZE_USE_HPX_THREADS)
endif()
endif()

include(CMakePackageConfigHelpers)
Expand Down Expand Up @@ -130,7 +141,6 @@ install(
)

# Optionally build tests (primarily for devs)
option(BLAZETENSOR_WITH_TESTS "Build BlazeTensor tests" OFF)
if(BLAZETENSOR_WITH_TESTS)
enable_testing()
include(CTest)
Expand Down
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -55,6 +55,10 @@ integration service tracks the current build status for the master branch:

### Datastructures

- `blaze::DynamicArray<N, T>`: a resizable, row-major ND dense array data structure
of arbitrary types
- `blaze::CustomArray<N, T, ...>`: a non-owning ND dense array data structure usable
to refer to some other ND dense array
- `blaze::DynamicTensor<T>`: a resizable, row-major 3D dense array data structure
of arbitrary types
- `blaze::CustomTensor<T, ...>`: a non-owning 3D dense array data structure usable
Expand Down Expand Up @@ -85,6 +89,9 @@ integration service tracks the current build status for the master branch:
tensor-like data structure with three additional argumnts: 'pagedilation',
'rowdilation' and 'columndilation' (step-size between the pages, rows and the
columns of the underlying tensor, respectively).
- `blaze::QuatSlice<...>`: a view representing a slice of 'thickness' one along
the page/row/column tensor of a 4D dense array

### Operations

- All element-wise arithmetic operations that are supported by the Blaze library:
Expand Down
2 changes: 2 additions & 0 deletions blaze_tensor/Math.h
Expand Up @@ -45,7 +45,9 @@

#include <blaze_tensor/math/Aliases.h>
#include <blaze_tensor/math/Constraints.h>
#include <blaze_tensor/math/CustomArray.h>
#include <blaze_tensor/math/CustomTensor.h>
#include <blaze_tensor/math/DynamicArray.h>
#include <blaze_tensor/math/DynamicTensor.h>
#include <blaze_tensor/math/UniformTensor.h>
#include <blaze_tensor/math/StaticTensor.h>
Expand Down
159 changes: 159 additions & 0 deletions blaze_tensor/math/Array.h
@@ -0,0 +1,159 @@
//=================================================================================================
/*!
// \file blaze_tensor/math/Array.h
// \brief Header file for all basic Array functionality
//
// Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved
// Copyright (C) 2018-2019 Hartmut Kaiser - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. Redistribution and use in source and binary
// forms, with or without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================

#ifndef _BLAZE_TENSOR_MATH_ARRAY_H_
#define _BLAZE_TENSOR_MATH_ARRAY_H_


//*************************************************************************************************
// Includes
//*************************************************************************************************

#include <array>
#include <iomanip>
#include <iosfwd>

#include <blaze/math/Matrix.h>

#include <blaze_tensor/math/expressions/Forward.h>
#include <blaze_tensor/math/expressions/Array.h>
#include <blaze_tensor/util/ArrayForEach.h>


namespace blaze {

//=================================================================================================
//
// GLOBAL FUNCTIONS
//
//=================================================================================================

//*************************************************************************************************
/*!\name Array functions */
//@{
template< typename MT >
bool isUniform( const Array<MT>& m );
//@}
//*************************************************************************************************


//*************************************************************************************************
/*!\brief Checks if the given tensor is a uniform tensor.
// \ingroup tensor
//
// \param m The tensor to be checked.
// \return \a true if the tensor is a uniform tensor, \a false if not.
//
// This function checks if the given dense or sparse tensor is a uniform tensor. The tensor
// is considered to be uniform if all its elements are identical. The following code example
// demonstrates the use of the function:
\code
blaze::Dynamictensor<int,blaze::rowMajor> A, B;
// ... Initialization
if( isUniform( A ) ) { ... }
\endcode
// Optionally, it is possible to switch between strict semantics (blaze::strict) and relaxed
// semantics (blaze::relaxed):
\code
if( isUniform<relaxed>( A ) ) { ... }
\endcode
// It is also possible to check if a tensor expression results in a uniform tensor:
\code
if( isUniform( A * B ) ) { ... }
\endcode
// However, note that this might require the complete evaluation of the expression, including
// the generation of a temporary tensor.
*/
template< typename MT > // Type of the tensor
inline bool isUniform( const Array<MT>& t )
{
return isUniform<relaxed>( ~t );
}
//*************************************************************************************************


//=================================================================================================
//
// GLOBAL OPERATORS
//
//=================================================================================================

//*************************************************************************************************
/*!\name Array operators */
//@{
template< typename MT >
inline std::ostream& operator<<( std::ostream& os, const Array<MT>& m );
//@}
//*************************************************************************************************


//*************************************************************************************************
/*!\brief Global output operator for dense and sparse tensors.
// \ingroup tensor
//
// \param os Reference to the output stream.
// \param m Reference to a constant tensor object.
// \return Reference to the output stream.
*/
template< typename MT >
inline std::ostream& operator<<( std::ostream& os, const Array<MT>& m )
{
CompositeType_t<MT> tmp( ~m );

ArrayForEachGrouped(
tmp.dimensions(),
[&]( std::array< size_t, MT::num_dimensions() > const& dims ) {
os << std::setw( 12 ) << tmp( dims ) << " ";
},
[&]( size_t ) { os << "("; },
[&]( size_t i ) {
os << ")";
if( i == 0 )
os << "\n";
} );

return os;
}
//*************************************************************************************************

} // namespace blaze

#endif
1 change: 1 addition & 0 deletions blaze_tensor/math/Constraints.h
Expand Up @@ -48,6 +48,7 @@
#include <blaze_tensor/math/constraints/MatExpandExpr.h>
#include <blaze_tensor/math/constraints/NumericTensor.h>
#include <blaze_tensor/math/constraints/PageSlice.h>
#include <blaze_tensor/math/constraints/QuatSlice.h>
#include <blaze_tensor/math/constraints/RowSlice.h>
#include <blaze_tensor/math/constraints/StorageOrder.h>
#include <blaze_tensor/math/constraints/Subtensor.h>
Expand Down

0 comments on commit aee39d0

Please sign in to comment.