├── .gitignore ├── LICENSE ├── README.md ├── examples ├── asl_demo │ ├── Readme.md │ ├── asl_arduino_nano_example.ino │ └── library.properties ├── asl_model.cpp └── person_detection │ ├── Readme.md │ ├── library.properties │ └── person_detect_arducam.ino ├── library.properties └── src ├── Eigen.h ├── Eigen ├── CMakeLists.txt ├── Cholesky ├── CholmodSupport ├── Core ├── Dense ├── Eigen ├── Eigenvalues ├── Geometry ├── Householder ├── IterativeLinearSolvers ├── Jacobi ├── LU ├── MetisSupport ├── OrderingMethods ├── PaStiXSupport ├── PardisoSupport ├── QR ├── QtAlignedMalloc ├── SPQRSupport ├── SVD ├── Sparse ├── SparseCholesky ├── SparseCore ├── SparseLU ├── SparseQR ├── StdDeque ├── StdList ├── StdVector ├── SuperLUSupport ├── UmfPackSupport └── src │ ├── Cholesky │ ├── LDLT.h │ ├── LLT.h │ └── LLT_LAPACKE.h │ ├── CholmodSupport │ └── CholmodSupport.h │ ├── Core │ ├── Array.h │ ├── ArrayBase.h │ ├── ArrayWrapper.h │ ├── Assign.h │ ├── AssignEvaluator.h │ ├── Assign_MKL.h │ ├── BandMatrix.h │ ├── Block.h │ ├── BooleanRedux.h │ ├── CommaInitializer.h │ ├── ConditionEstimator.h │ ├── CoreEvaluators.h │ ├── CoreIterators.h │ ├── CwiseBinaryOp.h │ ├── CwiseNullaryOp.h │ ├── CwiseTernaryOp.h │ ├── CwiseUnaryOp.h │ ├── CwiseUnaryView.h │ ├── DenseBase.h │ ├── DenseCoeffsBase.h │ ├── DenseStorage.h │ ├── Diagonal.h │ ├── DiagonalMatrix.h │ ├── DiagonalProduct.h │ ├── Dot.h │ ├── EigenBase.h │ ├── ForceAlignedAccess.h │ ├── Fuzzy.h │ ├── GeneralProduct.h │ ├── GenericPacketMath.h │ ├── GlobalFunctions.h │ ├── IO.h │ ├── Inverse.h │ ├── Map.h │ ├── MapBase.h │ ├── MathFunctions.h │ ├── MathFunctionsImpl.h │ ├── Matrix.h │ ├── MatrixBase.h │ ├── NestByValue.h │ ├── NoAlias.h │ ├── NumTraits.h │ ├── PermutationMatrix.h │ ├── PlainObjectBase.h │ ├── Product.h │ ├── ProductEvaluators.h │ ├── Random.h │ ├── Redux.h │ ├── Ref.h │ ├── Replicate.h │ ├── ReturnByValue.h │ ├── Reverse.h │ ├── Select.h │ ├── SelfAdjointView.h │ ├── SelfCwiseBinaryOp.h │ ├── Solve.h │ ├── SolveTriangular.h │ ├── SolverBase.h │ ├── StableNorm.h │ ├── Stride.h │ ├── Swap.h │ ├── Transpose.h │ ├── Transpositions.h │ ├── TriangularMatrix.h │ ├── VectorBlock.h │ ├── VectorwiseOp.h │ ├── Visitor.h │ ├── arch │ │ ├── AVX │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ └── TypeCasting.h │ │ ├── AVX512 │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ │ ├── AltiVec │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ │ ├── CUDA │ │ │ ├── Complex.h │ │ │ ├── Half.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ ├── PacketMathHalf.h │ │ │ └── TypeCasting.h │ │ ├── Default │ │ │ ├── ConjHelper.h │ │ │ └── Settings.h │ │ ├── NEON │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ │ ├── SSE │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ └── TypeCasting.h │ │ └── ZVector │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ ├── functors │ │ ├── AssignmentFunctors.h │ │ ├── BinaryFunctors.h │ │ ├── NullaryFunctors.h │ │ ├── StlFunctors.h │ │ ├── TernaryFunctors.h │ │ └── UnaryFunctors.h │ ├── products │ │ ├── GeneralBlockPanelKernel.h │ │ ├── GeneralMatrixMatrix.h │ │ ├── GeneralMatrixMatrixTriangular.h │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ ├── GeneralMatrixVector.h │ │ ├── GeneralMatrixVector_BLAS.h │ │ ├── Parallelizer.h │ │ ├── SelfadjointMatrixMatrix.h │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ ├── SelfadjointMatrixVector.h │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ ├── SelfadjointProduct.h │ │ ├── SelfadjointRank2Update.h │ │ ├── TriangularMatrixMatrix.h │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ ├── TriangularMatrixVector.h │ │ ├── TriangularMatrixVector_BLAS.h │ │ ├── TriangularSolverMatrix.h │ │ ├── TriangularSolverMatrix_BLAS.h │ │ └── TriangularSolverVector.h │ └── util │ │ ├── BlasUtil.h │ │ ├── Constants.h │ │ ├── DisableStupidWarnings.h │ │ ├── ForwardDeclarations.h │ │ ├── MKL_support.h │ │ ├── Macros.h │ │ ├── Memory.h │ │ ├── Meta.h │ │ ├── NonMPL2.h │ │ ├── ReenableStupidWarnings.h │ │ ├── StaticAssert.h │ │ └── XprHelper.h │ ├── Eigenvalues │ ├── ComplexEigenSolver.h │ ├── ComplexSchur.h │ ├── ComplexSchur_LAPACKE.h │ ├── EigenSolver.h │ ├── GeneralizedEigenSolver.h │ ├── GeneralizedSelfAdjointEigenSolver.h │ ├── HessenbergDecomposition.h │ ├── MatrixBaseEigenvalues.h │ ├── RealQZ.h │ ├── RealSchur.h │ ├── RealSchur_LAPACKE.h │ ├── SelfAdjointEigenSolver.h │ ├── SelfAdjointEigenSolver_LAPACKE.h │ └── Tridiagonalization.h │ ├── Geometry │ ├── AlignedBox.h │ ├── AngleAxis.h │ ├── EulerAngles.h │ ├── Homogeneous.h │ ├── Hyperplane.h │ ├── OrthoMethods.h │ ├── ParametrizedLine.h │ ├── Quaternion.h │ ├── Rotation2D.h │ ├── RotationBase.h │ ├── Scaling.h │ ├── Transform.h │ ├── Translation.h │ ├── Umeyama.h │ └── arch │ │ └── Geometry_SSE.h │ ├── Householder │ ├── BlockHouseholder.h │ ├── Householder.h │ └── HouseholderSequence.h │ ├── IterativeLinearSolvers │ ├── BasicPreconditioners.h │ ├── BiCGSTAB.h │ ├── ConjugateGradient.h │ ├── IncompleteCholesky.h │ ├── IncompleteLUT.h │ ├── IterativeSolverBase.h │ ├── LeastSquareConjugateGradient.h │ └── SolveWithGuess.h │ ├── Jacobi │ └── Jacobi.h │ ├── LU │ ├── Determinant.h │ ├── FullPivLU.h │ ├── InverseImpl.h │ ├── PartialPivLU.h │ ├── PartialPivLU_LAPACKE.h │ └── arch │ │ └── Inverse_SSE.h │ ├── MetisSupport │ └── MetisSupport.h │ ├── OrderingMethods │ ├── Amd.h │ ├── Eigen_Colamd.h │ └── Ordering.h │ ├── PaStiXSupport │ └── PaStiXSupport.h │ ├── PardisoSupport │ └── PardisoSupport.h │ ├── QR │ ├── ColPivHouseholderQR.h │ ├── ColPivHouseholderQR_LAPACKE.h │ ├── CompleteOrthogonalDecomposition.h │ ├── FullPivHouseholderQR.h │ ├── HouseholderQR.h │ └── HouseholderQR_LAPACKE.h │ ├── SPQRSupport │ └── SuiteSparseQRSupport.h │ ├── SVD │ ├── BDCSVD.h │ ├── JacobiSVD.h │ ├── JacobiSVD_LAPACKE.h │ ├── SVDBase.h │ └── UpperBidiagonalization.h │ ├── SparseCholesky │ ├── SimplicialCholesky.h │ └── SimplicialCholesky_impl.h │ ├── SparseCore │ ├── AmbiVector.h │ ├── CompressedStorage.h │ ├── ConservativeSparseSparseProduct.h │ ├── MappedSparseMatrix.h │ ├── SparseAssign.h │ ├── SparseBlock.h │ ├── SparseColEtree.h │ ├── SparseCompressedBase.h │ ├── SparseCwiseBinaryOp.h │ ├── SparseCwiseUnaryOp.h │ ├── SparseDenseProduct.h │ ├── SparseDiagonalProduct.h │ ├── SparseDot.h │ ├── SparseFuzzy.h │ ├── SparseMap.h │ ├── SparseMatrix.h │ ├── SparseMatrixBase.h │ ├── SparsePermutation.h │ ├── SparseProduct.h │ ├── SparseRedux.h │ ├── SparseRef.h │ ├── SparseSelfAdjointView.h │ ├── SparseSolverBase.h │ ├── SparseSparseProductWithPruning.h │ ├── SparseTranspose.h │ ├── SparseTriangularView.h │ ├── SparseUtil.h │ ├── SparseVector.h │ ├── SparseView.h │ └── TriangularSolver.h │ ├── SparseLU │ ├── SparseLU.h │ ├── SparseLUImpl.h │ ├── SparseLU_Memory.h │ ├── SparseLU_Structs.h │ ├── SparseLU_SupernodalMatrix.h │ ├── SparseLU_Utils.h │ ├── SparseLU_column_bmod.h │ ├── SparseLU_column_dfs.h │ ├── SparseLU_copy_to_ucol.h │ ├── SparseLU_gemm_kernel.h │ ├── SparseLU_heap_relax_snode.h │ ├── SparseLU_kernel_bmod.h │ ├── SparseLU_panel_bmod.h │ ├── SparseLU_panel_dfs.h │ ├── SparseLU_pivotL.h │ ├── SparseLU_pruneL.h │ └── SparseLU_relax_snode.h │ ├── SparseQR │ └── SparseQR.h │ ├── StlSupport │ ├── StdDeque.h │ ├── StdList.h │ ├── StdVector.h │ └── details.h │ ├── SuperLUSupport │ └── SuperLUSupport.h │ ├── UmfPackSupport │ └── UmfPackSupport.h │ ├── misc │ ├── Image.h │ ├── Kernel.h │ ├── RealSvd2x2.h │ ├── blas.h │ ├── lapack.h │ ├── lapacke.h │ └── lapacke_mangling.h │ └── plugins │ ├── ArrayCwiseBinaryOps.h │ ├── ArrayCwiseUnaryOps.h │ ├── BlockMethods.h │ ├── CommonCwiseBinaryOps.h │ ├── CommonCwiseUnaryOps.h │ ├── MatrixCwiseBinaryOps.h │ └── MatrixCwiseUnaryOps.h ├── core ├── broadcast.h ├── datatypes.h ├── flag.h ├── iterator.h ├── macros.h ├── placeHolder.h └── tensor.h ├── deepC.h └── operators ├── Abs.h ├── Acos.h ├── Acosh.h ├── Add.h ├── And.h ├── ArgMax.h ├── ArgMin.h ├── Asin.h ├── Asinh.h ├── Atan.h ├── Atanh.h ├── AveragePool.h ├── BatchNormalization.h ├── BitShift.h ├── BitwiseAnd.h ├── BitwiseOr.h ├── BitwiseXor.h ├── Cast.h ├── Ceil.h ├── Clip.h ├── Compress.h ├── Concat.h ├── Constant.h ├── ConstantOfShape.h ├── Conv.h ├── ConvInteger.h ├── ConvTranspose.h ├── Cos.h ├── Cosh.h ├── CumSum.h ├── DepthToSpace.h ├── DequantizeLinear.h ├── Div.h ├── Dropout.h ├── Elu.h ├── Equal.h ├── Erf.h ├── Exp.h ├── Expand.h ├── EyeLike.h ├── Flatten.h ├── Floor.h ├── FloorDiv.h ├── GRU.h ├── Gather.h ├── Gemm.h ├── GlobalAveragePool.h ├── GlobalLpPool.h ├── GlobalMaxPool.h ├── Greater.h ├── GreaterEqual.h ├── HardSigmoid.h ├── Hardmax.h ├── Identity.h ├── If.h ├── InstanceNormalization.h ├── IsInf.h ├── IsNaN.h ├── LRN.h ├── LSTM.h ├── LeakyRelu.h ├── Less.h ├── LessEqual.h ├── Log.h ├── LogSoftmax.h ├── Loop.h ├── LpNormalization.h ├── LpPool.h ├── MatMul.h ├── MatMulInteger.h ├── Max.h ├── MaxPool.h ├── MaxRoiPool.h ├── MaxUnpool.h ├── Mean.h ├── Min.h ├── Mod.h ├── Mul.h ├── Multinomial.h ├── Neg.h ├── NonMaxSuppression.h ├── NonZero.h ├── Not.h ├── NotEqual.h ├── OneHot.h ├── Or.h ├── PRelu.h ├── Pad.h ├── Pow.h ├── QLinearConv.h ├── QLinearMatMul.h ├── QuantizeLinear.h ├── RNN.h ├── RandomNormal.h ├── RandomNormalLike.h ├── RandomUniform.h ├── RandomUniformLike.h ├── Reciprocal.h ├── ReduceL1.h ├── ReduceL2.h ├── ReduceLogSum.h ├── ReduceLogSumExp.h ├── ReduceMax.h ├── ReduceMean.h ├── ReduceMin.h ├── ReduceProd.h ├── ReduceSum.h ├── ReduceSumSquare.h ├── Relu.h ├── Remainder.h ├── Reshape.h ├── Resize.h ├── ReverseSequence.h ├── RoiAlign.h ├── Round.h ├── Scan.h ├── Scatter.h ├── Selu.h ├── SetSlice.h ├── Shape.h ├── Shrink.h ├── Sigmoid.h ├── Sign.h ├── Sin.h ├── Sinh.h ├── Size.h ├── Slice.h ├── Softmax.h ├── Softplus.h ├── Softsign.h ├── SpaceToDepth.h ├── Split.h ├── Sqrt.h ├── Squeeze.h ├── StringNormalizer.h ├── Sub.h ├── Sum.h ├── Tan.h ├── Tanh.h ├── TfIdfVectorizer.h ├── ThresholdedRelu.h ├── Tile.h ├── TopK.h ├── Transpose.h ├── TrueDiv.h ├── Unsqueeze.h ├── Upsample.h ├── Where.h ├── Xor.h ├── baseOperator.h ├── macros.h └── opTypes.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # deepC for arduino 2 | 3 | deepC is an open source deep learning framework for on-device inference on embedded devices. This repository is adapted for arduino devices. It enables low-latency inference of on-device machine learning models with a small binary size with low memory and high performance. 4 | 5 | # KPNS 6 | ### 1. add -fexceptions, and remove -fno-exceptions 7 | to the compiler flags to the platform.txt of your Arduino IDE installation files given below: 8 | - ${ARDUINO_INSTALLATION}/.arduino15/packages/arduino/hardware/mbed/1.1.4/variants/ARDUINO_NANO33BLE/cxxflags.txt 9 | - ${ARDUINO_INSTALLATION}/arduino-1.8.12/hardware/arduino/avr/platform.txt 10 | -------------------------------------------------------------------------------- /examples/asl_demo/Readme.md: -------------------------------------------------------------------------------- 1 | asl_demo_arduino_example.ino contains the application for American Sign Language on Arduino Nano 33 BLE Sense. 2 | 3 | How to install visual_wake_word library for Arduino IDE? 4 | - Find the path for your arduino IDE installation. For me, it was ~/arduino 5 | - mkdir -p ~/arduino/libraries/asl_imu/src/cortex-m4 6 | - cp ndarray.h visual_wake_word.h ~/arduino/libraries/asl_imu/src 7 | - cp lib_asl_imu.a ~/arduino/libraries/asl_imu/src/cortex-m4/asl_imu.a 8 | - cp library.properties ~/arduino/libraries/asl_imu 9 | -------------------------------------------------------------------------------- /examples/asl_demo/library.properties: -------------------------------------------------------------------------------- 1 | name=asl_imu 2 | version=0.12 3 | author=Praveen Jain et. al. 4 | maintainer=Praveen Jain 5 | sentence=Allows you to run machine learning models locally on arduino boards. 6 | paragraph=This library runs deepC machine learning models on microcontrollers, allowing you to build AI/ML applications powered by deep learning and neural networks. With the included examples, you can recognize speech, detect people using a camera, and recognise asl gestures using an accelerometer. The examples work best with the Arduino Nano 33 BLE Sense board, which has a microphone and accelerometer. 7 | url=https://github.com/ai-techsystems/arduino 8 | category=Data Processing 9 | ldflags=-lm 10 | includes=asl_imu.h 11 | precompiled=true 12 | -------------------------------------------------------------------------------- /examples/person_detection/Readme.md: -------------------------------------------------------------------------------- 1 | person_detect_arducam.ino contains the application for person detection on Arduino Nano 33 with ArduCAM. 2 | 3 | How to install visual_wake_word library for Arduino IDE? 4 | - Find the path for your arduino IDE installation. For me, it was ~/arduino 5 | - mkdir -p ~/arduino/libraries/visual_wake_word/src/cortex-m4 6 | - cp ndarray.h visual_wake_word.h ~/arduino/libraries/visual_wake_word/src 7 | - cp lib_visual_wake_word.a ~/arduino/libraries/visual_wake_word/src/cortex-m4/visual_wake_word.a 8 | - cp library.properties ~/arduino/libraries/visual_wake_word 9 | -------------------------------------------------------------------------------- /examples/person_detection/library.properties: -------------------------------------------------------------------------------- 1 | name=visual_wake_word 2 | version=0.1 3 | author=Praveen Jain et. al. 4 | maintainer=Praveen Jain 5 | sentence=Allows you to run object classification machine learning model locally on arduino boards. 6 | paragraph=This library runs deepSea machine learning models on microcontrollers, allowing you to build AI/ML applications powered by deep learning and neural networks. With this example, you can recognize person in an image captured by ArduCAM on Arduino Nano 33 BLE Sense. You can also detect speech, and recognise asl gestures using an accelerometer. The examples work best with the Arduino Nano 33 BLE Sense board, which has a microphone and accelerometer and other sensors. 7 | url=https://github.com/ai-techsystems/arduino 8 | category=Machine Learning 9 | ldflags=-lm 10 | includes=visual_wake_word.h 11 | precompiled=true 12 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=deepC 2 | version=0.12 3 | author=Rohit Sharma et. al. 4 | maintainer=Rohit Sharma 5 | sentence=Allows you to run machine learning models locally on arduino boards. 6 | paragraph=This library runs deepC machine learning models on microcontrollers, allowing you to build AI/ML applications powered by deep learning and neural networks. With the included examples, you can recognize speech, detect people using a camera, and recognise asl gestures using an accelerometer. The examples work best with the Arduino Nano 33 BLE Sense board, which has a microphone and accelerometer. 7 | category=Data Processing 8 | url=https://github.com/ai-techsystems/arduino 9 | ldflags=-lm 10 | includes=deepC.h 11 | -------------------------------------------------------------------------------- /src/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h") 20 | -------------------------------------------------------------------------------- /src/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | #include "Jacobi" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** \defgroup Cholesky_Module Cholesky module 17 | * 18 | * 19 | * 20 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 21 | * Those decompositions are also accessible via the following methods: 22 | * - MatrixBase::llt() 23 | * - MatrixBase::ldlt() 24 | * - SelfAdjointView::llt() 25 | * - SelfAdjointView::ldlt() 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | */ 31 | 32 | #include "src/Cholesky/LLT.h" 33 | #include "src/Cholesky/LDLT.h" 34 | #ifdef EIGEN_USE_LAPACKE 35 | #ifdef EIGEN_USE_MKL 36 | #include "mkl_lapacke.h" 37 | #else 38 | #include "src/misc/lapacke.h" 39 | #endif 40 | #include "src/Cholesky/LLT_LAPACKE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_CHOLESKY_MODULE_H 46 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 47 | -------------------------------------------------------------------------------- /src/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 9 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup CholmodSupport_Module CholmodSupport module 21 | * 22 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 23 | * It provides the two following main factorization classes: 24 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 25 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 26 | * 27 | * For the sake of completeness, this module also propose the two following classes: 28 | * - class CholmodSimplicialLLT 29 | * - class CholmodSimplicialLDLT 30 | * Note that these classes does not bring any particular advantage compared to the built-in 31 | * SimplicialLLT and SimplicialLDLT factorization classes. 32 | * 33 | * \code 34 | * #include 35 | * \endcode 36 | * 37 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 38 | * The dependencies depend on how cholmod has been compiled. 39 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 40 | * 41 | */ 42 | 43 | #include "src/CholmodSupport/CholmodSupport.h" 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 48 | 49 | -------------------------------------------------------------------------------- /src/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /src/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /src/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_EIGENVALUES_MODULE_H 9 | #define EIGEN_EIGENVALUES_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | #include "LU" 19 | #include "Geometry" 20 | 21 | /** \defgroup Eigenvalues_Module Eigenvalues module 22 | * 23 | * 24 | * 25 | * This module mainly provides various eigenvalue solvers. 26 | * This module also provides some MatrixBase methods, including: 27 | * - MatrixBase::eigenvalues(), 28 | * - MatrixBase::operatorNorm() 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/misc/RealSvd2x2.h" 36 | #include "src/Eigenvalues/Tridiagonalization.h" 37 | #include "src/Eigenvalues/RealSchur.h" 38 | #include "src/Eigenvalues/EigenSolver.h" 39 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 40 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 41 | #include "src/Eigenvalues/HessenbergDecomposition.h" 42 | #include "src/Eigenvalues/ComplexSchur.h" 43 | #include "src/Eigenvalues/ComplexEigenSolver.h" 44 | #include "src/Eigenvalues/RealQZ.h" 45 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 46 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 47 | #ifdef EIGEN_USE_LAPACKE 48 | #ifdef EIGEN_USE_MKL 49 | #include "mkl_lapacke.h" 50 | #else 51 | #include "src/misc/lapacke.h" 52 | #endif 53 | #include "src/Eigenvalues/RealSchur_LAPACKE.h" 54 | #include "src/Eigenvalues/ComplexSchur_LAPACKE.h" 55 | #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_EIGENVALUES_MODULE_H 61 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 62 | -------------------------------------------------------------------------------- /src/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_GEOMETRY_MODULE_H 9 | #define EIGEN_GEOMETRY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SVD" 16 | #include "LU" 17 | #include 18 | 19 | /** \defgroup Geometry_Module Geometry module 20 | * 21 | * This module provides support for: 22 | * - fixed-size homogeneous transformations 23 | * - translation, scaling, 2D and 3D rotations 24 | * - \link Quaternion quaternions \endlink 25 | * - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3) 26 | * - orthognal vector generation (\ref MatrixBase::unitOrthogonal) 27 | * - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink 28 | * - \link AlignedBox axis aligned bounding boxes \endlink 29 | * - \link umeyama least-square transformation fitting \endlink 30 | * 31 | * \code 32 | * #include 33 | * \endcode 34 | */ 35 | 36 | #include "src/Geometry/OrthoMethods.h" 37 | #include "src/Geometry/EulerAngles.h" 38 | 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | // Use the SSE optimized version whenever possible. At the moment the 53 | // SSE version doesn't compile when AVX is enabled 54 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 55 | #include "src/Geometry/arch/Geometry_SSE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_GEOMETRY_MODULE_H 61 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 62 | 63 | -------------------------------------------------------------------------------- /src/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 31 | -------------------------------------------------------------------------------- /src/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 9 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** 17 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 18 | * 19 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 20 | * Those solvers are accessible via the following classes: 21 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 22 | * - LeastSquaresConjugateGradient for rectangular least-square problems, 23 | * - BiCGSTAB for general square matrices. 24 | * 25 | * These iterative solvers are associated with some preconditioners: 26 | * - IdentityPreconditioner - not really useful 27 | * - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices. 28 | * - IncompleteLUT - incomplete LU factorization with dual thresholding 29 | * 30 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 31 | * 32 | \code 33 | #include 34 | \endcode 35 | */ 36 | 37 | #include "src/IterativeLinearSolvers/SolveWithGuess.h" 38 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 39 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 40 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 41 | #include "src/IterativeLinearSolvers/LeastSquareConjugateGradient.h" 42 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 43 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 44 | #include "src/IterativeLinearSolvers/IncompleteCholesky.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 49 | -------------------------------------------------------------------------------- /src/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | 34 | -------------------------------------------------------------------------------- /src/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #ifdef EIGEN_USE_MKL 32 | #include "mkl_lapacke.h" 33 | #else 34 | #include "src/misc/lapacke.h" 35 | #endif 36 | #include "src/LU/PartialPivLU_LAPACKE.h" 37 | #endif 38 | #include "src/LU/Determinant.h" 39 | #include "src/LU/InverseImpl.h" 40 | 41 | // Use the SSE optimized version whenever possible. At the moment the 42 | // SSE version doesn't compile when AVX is enabled 43 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 44 | #include "src/LU/arch/Inverse_SSE.h" 45 | #endif 46 | 47 | #include "src/Core/util/ReenableStupidWarnings.h" 48 | 49 | #endif // EIGEN_LU_MODULE_H 50 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 51 | -------------------------------------------------------------------------------- /src/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 9 | #define EIGEN_PASTIXSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | #ifdef complex 21 | #undef complex 22 | #endif 23 | 24 | /** \ingroup Support_modules 25 | * \defgroup PaStiXSupport_Module PaStiXSupport module 26 | * 27 | * This module provides an interface to the PaSTiX library. 28 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 29 | * It provides the two following main factorization classes: 30 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 31 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 32 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 33 | * 34 | * \code 35 | * #include 36 | * \endcode 37 | * 38 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 39 | * The dependencies depend on how PaSTiX has been compiled. 40 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 41 | * 42 | */ 43 | 44 | #include "src/PaStiXSupport/PaStiXSupport.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 49 | -------------------------------------------------------------------------------- /src/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #ifdef EIGEN_USE_MKL 40 | #include "mkl_lapacke.h" 41 | #else 42 | #include "src/misc/lapacke.h" 43 | #endif 44 | #include "src/QR/HouseholderQR_LAPACKE.h" 45 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_QR_MODULE_H 51 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 52 | -------------------------------------------------------------------------------- /src/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | std::memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 41 | -------------------------------------------------------------------------------- /src/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #ifdef EIGEN_USE_MKL 41 | #include "mkl_lapacke.h" 42 | #else 43 | #include "src/misc/lapacke.h" 44 | #endif 45 | #include "src/SVD/JacobiSVD_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SVD_MODULE_H 51 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 52 | -------------------------------------------------------------------------------- /src/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #ifndef EIGEN_MPL2_ONLY 29 | #include "SparseCholesky" 30 | #endif 31 | #include "SparseLU" 32 | #include "SparseQR" 33 | #include "IterativeLinearSolvers" 34 | 35 | #endif // EIGEN_SPARSE_MODULE_H 36 | 37 | -------------------------------------------------------------------------------- /src/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/SparseCholesky/SimplicialCholesky.h" 38 | 39 | #ifndef EIGEN_MPL2_ONLY 40 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 46 | -------------------------------------------------------------------------------- /src/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | // Ordering interface 24 | #include "OrderingMethods" 25 | 26 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 27 | 28 | #include "src/SparseLU/SparseLU_Structs.h" 29 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 30 | #include "src/SparseLU/SparseLUImpl.h" 31 | #include "src/SparseCore/SparseColEtree.h" 32 | #include "src/SparseLU/SparseLU_Memory.h" 33 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 34 | #include "src/SparseLU/SparseLU_relax_snode.h" 35 | #include "src/SparseLU/SparseLU_pivotL.h" 36 | #include "src/SparseLU/SparseLU_panel_dfs.h" 37 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 38 | #include "src/SparseLU/SparseLU_panel_bmod.h" 39 | #include "src/SparseLU/SparseLU_column_dfs.h" 40 | #include "src/SparseLU/SparseLU_column_bmod.h" 41 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 42 | #include "src/SparseLU/SparseLU_pruneL.h" 43 | #include "src/SparseLU/SparseLU_Utils.h" 44 | #include "src/SparseLU/SparseLU.h" 45 | 46 | #endif // EIGEN_SPARSELU_MODULE_H 47 | -------------------------------------------------------------------------------- /src/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "OrderingMethods" 32 | #include "src/SparseCore/SparseColEtree.h" 33 | #include "src/SparseQR/SparseQR.h" 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /src/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /src/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /src/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/SelfCwiseBinaryOp.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SELFCWISEBINARYOP_H 11 | #define EIGEN_SELFCWISEBINARYOP_H 12 | 13 | namespace Eigen { 14 | 15 | // TODO generalize the scalar type of 'other' 16 | 17 | template 18 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) 19 | { 20 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op()); 21 | return derived(); 22 | } 23 | 24 | template 25 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator+=(const Scalar& other) 26 | { 27 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op()); 28 | return derived(); 29 | } 30 | 31 | template 32 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator-=(const Scalar& other) 33 | { 34 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op()); 35 | return derived(); 36 | } 37 | 38 | template 39 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) 40 | { 41 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op()); 42 | return derived(); 43 | } 44 | 45 | } // end namespace Eigen 46 | 47 | #endif // EIGEN_SELFCWISEBINARYOP_H 48 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/AVX/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX_H 11 | #define EIGEN_TYPE_CASTING_AVX_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // For now we use SSE to handle integers, so we can't use AVX instructions to cast 18 | // from int to float 19 | template <> 20 | struct type_casting_traits { 21 | enum { 22 | VectorizedCast = 0, 23 | SrcCoeffRatio = 1, 24 | TgtCoeffRatio = 1 25 | }; 26 | }; 27 | 28 | template <> 29 | struct type_casting_traits { 30 | enum { 31 | VectorizedCast = 0, 32 | SrcCoeffRatio = 1, 33 | TgtCoeffRatio = 1 34 | }; 35 | }; 36 | 37 | 38 | 39 | template<> EIGEN_STRONG_INLINE Packet8i pcast(const Packet8f& a) { 40 | return _mm256_cvtps_epi32(a); 41 | } 42 | 43 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i& a) { 44 | return _mm256_cvtepi32_ps(a); 45 | } 46 | 47 | } // end namespace internal 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_TYPE_CASTING_AVX_H 52 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/Default/ConjHelper.h: -------------------------------------------------------------------------------- 1 | 2 | // This file is part of Eigen, a lightweight C++ template library 3 | // for linear algebra. 4 | // 5 | // Copyright (C) 2017 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_ARCH_CONJ_HELPER_H 12 | #define EIGEN_ARCH_CONJ_HELPER_H 13 | 14 | #define EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(PACKET_CPLX, PACKET_REAL) \ 15 | template<> struct conj_helper { \ 16 | EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_REAL& x, const PACKET_CPLX& y, const PACKET_CPLX& c) const \ 17 | { return padd(c, pmul(x,y)); } \ 18 | EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_REAL& x, const PACKET_CPLX& y) const \ 19 | { return PACKET_CPLX(Eigen::internal::pmul(x, y.v)); } \ 20 | }; \ 21 | \ 22 | template<> struct conj_helper { \ 23 | EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_CPLX& x, const PACKET_REAL& y, const PACKET_CPLX& c) const \ 24 | { return padd(c, pmul(x,y)); } \ 25 | EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_CPLX& x, const PACKET_REAL& y) const \ 26 | { return PACKET_CPLX(Eigen::internal::pmul(x.v, y)); } \ 27 | }; 28 | 29 | #endif // EIGEN_ARCH_CONJ_HELPER_H 30 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/SSE/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_SSE_H 11 | #define EIGEN_TYPE_CASTING_SSE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | #ifndef EIGEN_VECTORIZE_AVX 18 | template <> 19 | struct type_casting_traits { 20 | enum { 21 | VectorizedCast = 1, 22 | SrcCoeffRatio = 1, 23 | TgtCoeffRatio = 1 24 | }; 25 | }; 26 | 27 | template <> 28 | struct type_casting_traits { 29 | enum { 30 | VectorizedCast = 1, 31 | SrcCoeffRatio = 1, 32 | TgtCoeffRatio = 1 33 | }; 34 | }; 35 | 36 | template <> 37 | struct type_casting_traits { 38 | enum { 39 | VectorizedCast = 1, 40 | SrcCoeffRatio = 2, 41 | TgtCoeffRatio = 1 42 | }; 43 | }; 44 | 45 | template <> 46 | struct type_casting_traits { 47 | enum { 48 | VectorizedCast = 1, 49 | SrcCoeffRatio = 1, 50 | TgtCoeffRatio = 2 51 | }; 52 | }; 53 | #endif 54 | 55 | template<> EIGEN_STRONG_INLINE Packet4i pcast(const Packet4f& a) { 56 | return _mm_cvttps_epi32(a); 57 | } 58 | 59 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet4i& a) { 60 | return _mm_cvtepi32_ps(a); 61 | } 62 | 63 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet2d& a, const Packet2d& b) { 64 | return _mm_shuffle_ps(_mm_cvtpd_ps(a), _mm_cvtpd_ps(b), (1 << 2) | (1 << 6)); 65 | } 66 | 67 | template<> EIGEN_STRONG_INLINE Packet2d pcast(const Packet4f& a) { 68 | // Simply discard the second half of the input 69 | return _mm_cvtps_pd(a); 70 | } 71 | 72 | 73 | } // end namespace internal 74 | 75 | } // end namespace Eigen 76 | 77 | #endif // EIGEN_TYPE_CASTING_SSE_H 78 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #elif defined __GNUC__ && __GNUC__>=6 12 | #pragma GCC diagnostic pop 13 | #endif 14 | 15 | #if defined __NVCC__ 16 | // Don't reenable the diagnostic messages, as it turns out these messages need 17 | // to be disabled at the point of the template instantiation (i.e the user code) 18 | // otherwise they'll be triggered by nvcc. 19 | // #pragma diag_default code_is_unreachable 20 | // #pragma diag_default initialization_not_reachable 21 | // #pragma diag_default 2651 22 | // #pragma diag_default 2653 23 | #endif 24 | 25 | #endif 26 | 27 | #endif // EIGEN_WARNINGS_DISABLED 28 | -------------------------------------------------------------------------------- /src/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /src/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | internal::evaluator thisEval(derived()); 22 | for (Index j=0; j::InnerIterator iter(thisEval,j); iter; ++iter) 24 | res += iter.value(); 25 | return res; 26 | } 27 | 28 | template 29 | typename internal::traits >::Scalar 30 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | if(this->isCompressed()) 34 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 35 | else 36 | return Base::sum(); 37 | } 38 | 39 | template 40 | typename internal::traits >::Scalar 41 | SparseVector<_Scalar,_Options,_Index>::sum() const 42 | { 43 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 44 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 45 | } 46 | 47 | } // end namespace Eigen 48 | 49 | #endif // EIGEN_SPARSEREDUX_H 50 | -------------------------------------------------------------------------------- /src/Eigen/src/misc/RealSvd2x2.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Benoit Jacob 5 | // Copyright (C) 2013-2016 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_REALSVD2X2_H 12 | #define EIGEN_REALSVD2X2_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, 20 | JacobiRotation *j_left, 21 | JacobiRotation *j_right) 22 | { 23 | using std::sqrt; 24 | using std::abs; 25 | Matrix m; 26 | m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), 27 | numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); 28 | JacobiRotation rot1; 29 | RealScalar t = m.coeff(0,0) + m.coeff(1,1); 30 | RealScalar d = m.coeff(1,0) - m.coeff(0,1); 31 | 32 | if(abs(d) < (std::numeric_limits::min)()) 33 | { 34 | rot1.s() = RealScalar(0); 35 | rot1.c() = RealScalar(1); 36 | } 37 | else 38 | { 39 | // If d!=0, then t/d cannot overflow because the magnitude of the 40 | // entries forming d are not too small compared to the ones forming t. 41 | RealScalar u = t / d; 42 | RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u)); 43 | rot1.s() = RealScalar(1) / tmp; 44 | rot1.c() = u / tmp; 45 | } 46 | m.applyOnTheLeft(0,1,rot1); 47 | j_right->makeJacobi(m,0,1); 48 | *j_left = rot1 * j_right->transpose(); 49 | } 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_REALSVD2X2_H 56 | -------------------------------------------------------------------------------- /src/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /src/core/flag.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | #pragma once 24 | 25 | namespace dnnc { 26 | /*!< This class uses individual bits to store ENUM information 27 | * for any given object. Efficient in storage and compute. 28 | * It can accomodate upto 15 enums */ 29 | class flag { 30 | protected: 31 | short _info; 32 | 33 | public: 34 | flag() : _info(0){}; 35 | flag(short info) : _info(info) {} 36 | bool get(short index) const { return _info & (1 << index); } 37 | void set(short index) { _info |= (1 << index); } 38 | void reset(short index) { _info &= ~(1 << index); } 39 | flag operator|(const flag &rhs) const { return _info | rhs._info; } 40 | bool operator<(const flag &rhs) const { return (_info < rhs._info); } 41 | }; 42 | } // namespace dnnc 43 | -------------------------------------------------------------------------------- /src/deepC.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 The deepC Authors. All Rights Reserved. 2 | https://github.com/ai-techsystems/dnnCompiler 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ==============================================================================*/ 16 | 17 | // This header is deliberately empty, and is only present because including it 18 | // in a .ino sketch forces the Arduino toolchain to build the rest of the 19 | // library. 20 | 21 | -------------------------------------------------------------------------------- /src/operators/Abs.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | namespace dnnc { 30 | template class Abs : public baseOperator { 31 | public: 32 | Abs(std::string name = "opAbs") : baseOperator(opAbs, name) {} 33 | 34 | tensor compute(tensor &a) { 35 | 36 | if (!(this->template type_check())) { 37 | SPDLOG_ERROR("Constrain input tensors to numeric tensors."); 38 | return NULL_TENSOR; 39 | } 40 | tensor result(a.shape(), a.name()); 41 | 42 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 43 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 44 | eResult.array() = abs(eigenVector.array()); 45 | result.load(eResult.data()); 46 | 47 | return result; 48 | } 49 | }; 50 | } // namespace dnnc 51 | -------------------------------------------------------------------------------- /src/operators/Acos.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | #include 28 | using namespace Eigen; 29 | using namespace std; 30 | namespace dnnc { 31 | template class Acos : public baseOperator { 32 | public: 33 | Acos(std::string name = "opAcos") : baseOperator(opAcos, name) {} 34 | 35 | tensor compute(tensor &a) { 36 | 37 | if (!(this->template type_check())) { 38 | SPDLOG_ERROR("Constrain input tensors to numeric tensors."); 39 | return NULL_TENSOR; 40 | } 41 | 42 | tensor result(a.shape()); 43 | 44 | for (size_t i = 0; i < a.length(); i++) { 45 | float x = a[i]; 46 | if (x < -1 && x > 1) { 47 | SPDLOG_ERROR("The tensor elements are not in the domain of arc cosine"); 48 | return NULL_TENSOR; 49 | } 50 | result[i] = acos(x); 51 | } 52 | 53 | return result; 54 | } 55 | }; 56 | } // namespace dnnc 57 | -------------------------------------------------------------------------------- /src/operators/Acosh.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | using namespace std; 30 | namespace dnnc { 31 | template class Acosh : public baseOperator { 32 | public: 33 | Acosh(std::string name = "opAcosh") : baseOperator(opAcosh, name) {} 34 | 35 | tensor compute(tensor &a) { 36 | 37 | if (!(this->template type_check())) { 38 | SPDLOG_ERROR("Constrain input tensors to numeric tensors."); 39 | return NULL_TENSOR; 40 | } 41 | 42 | tensor result(a.shape()); 43 | 44 | for (size_t i = 0; i < a.length(); i++) { 45 | float x = a[i]; 46 | if (0 >= x) { 47 | SPDLOG_ERROR("Tensor value is negative cannot calculate ACOSH"); 48 | return NULL_TENSOR; 49 | } 50 | result[i] = log(x + sqrt(x * x - 1)); 51 | } 52 | 53 | return result; 54 | } 55 | }; 56 | } // namespace dnnc 57 | -------------------------------------------------------------------------------- /src/operators/Asin.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Asin : public baseOperator { 32 | public: 33 | Asin(std::string name = "opAsin") : baseOperator(opAsin, name) {} 34 | 35 | tensor compute(tensor &a) { 36 | 37 | tensor result(a.shape()); 38 | 39 | for (size_t i = 0; i < a.length(); i++) { 40 | float x = a[i]; 41 | if (x < -1 && x > 1) { 42 | SPDLOG_ERROR("Error : the value of tensor element is not " 43 | "lying in the domain of arc sine "); 44 | return NULL_TENSOR; 45 | } 46 | result[i] = asin(x); 47 | } 48 | 49 | return result; 50 | } 51 | }; 52 | } // namespace dnnc 53 | -------------------------------------------------------------------------------- /src/operators/Asinh.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Asinh : public baseOperator { 32 | public: 33 | Asinh(std::string name = "opAsinh") : baseOperator(opAsinh, name) {} 34 | 35 | tensor compute(tensor &a) { 36 | 37 | if (!(this->template type_check())) { 38 | SPDLOG_ERROR("Constrain input tensors to numeric tensors."); 39 | return NULL_TENSOR; 40 | } 41 | 42 | tensor result(a.shape()); 43 | 44 | for (size_t i = 0; i < a.length(); i++) { 45 | float x = a[i]; 46 | result[i] = log(x + sqrt(x * x + 1)); 47 | } 48 | 49 | return result; 50 | } 51 | }; 52 | } // namespace dnnc 53 | -------------------------------------------------------------------------------- /src/operators/Atan.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Atan : public baseOperator { 32 | 33 | public: 34 | Atan(std::string name = "opAtan") : baseOperator(opAtan, name) {} 35 | 36 | tensor compute(tensor &a) { 37 | 38 | if (!(this->template type_check())) { 39 | SPDLOG_ERROR("Constrain input tensors to numeric tensors."); 40 | return NULL_TENSOR; 41 | } 42 | 43 | tensor result(a.shape()); 44 | 45 | for (size_t i = 0; i < a.length(); i++) { 46 | float x = a[i]; 47 | result[i] = atan(x); 48 | } 49 | 50 | return result; 51 | } 52 | }; 53 | } // namespace dnnc 54 | -------------------------------------------------------------------------------- /src/operators/Atanh.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Atanh : public baseOperator { 32 | public: 33 | Atanh(std::string name = "opAtanh") : baseOperator(opAtanh, name) {} 34 | 35 | tensor compute(tensor &a) { 36 | 37 | if (!(this->template type_check())) { 38 | SPDLOG_ERROR("Constrain input tensors to numeric tensors."); 39 | return a; 40 | } 41 | 42 | tensor result(a.shape(), a.name()); 43 | for (size_t i = 0; i < a.length(); i++) { 44 | float x = a[i]; 45 | if (x < -1 && x > 1) { 46 | SPDLOG_ERROR("Error : the value of tensor element is less than 0"); 47 | return NULL_TENSOR; 48 | } else 49 | result[i] = 0.5 * (log((x + 1)) - log((x - 1))); 50 | } 51 | 52 | return result; 53 | } 54 | }; 55 | } // namespace dnnc 56 | -------------------------------------------------------------------------------- /src/operators/AveragePool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class AveragePool : public baseOperator { 32 | // AveragePool attributes 33 | public: 34 | AveragePool(std::string name = "opAveragePool") 35 | : baseOperator(opAveragePool, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/BatchNormalization.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class BatchNormalization : public baseOperator { 32 | // BatchNormalization attributes 33 | public: 34 | BatchNormalization(std::string name = "opBatchNormalization") 35 | : baseOperator(opBatchNormalization, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Cast.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Cast : public baseOperator { 32 | // Cast attributes 33 | public: 34 | Cast(std::string name = "opCast") : baseOperator(opCast, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Ceil.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | #include 28 | 29 | using namespace Eigen; 30 | 31 | namespace dnnc { 32 | template class Ceil : public baseOperator { 33 | // Ceil attributes 34 | public: 35 | Ceil(std::string name = "opCeil") : baseOperator(opCeil, name) {} 36 | 37 | tensor compute(tensor a) { 38 | if (!(this->template type_check())) { 39 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 40 | return NULL_TENSOR; 41 | } 42 | 43 | tensor result(a.shape(), a.name()); 44 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 45 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 46 | eResult.array() = Eigen::ceil(eigenVector.array()); 47 | 48 | result.load(eResult.data()); 49 | return result; 50 | } 51 | }; 52 | } // namespace dnnc 53 | -------------------------------------------------------------------------------- /src/operators/Clip.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | #include 28 | 29 | using namespace Eigen; 30 | 31 | namespace dnnc { 32 | template class Clip : public baseOperator { 33 | // Clip attributes 34 | public: 35 | Clip(std::string name = "opClip") : baseOperator(opClip, name) {} 36 | 37 | static T clipper(T x, T min, T max) { 38 | if (x > max) 39 | return max; 40 | else if (x < min) 41 | return min; 42 | else 43 | return x; 44 | } 45 | 46 | tensor compute(tensor a, T &min, T &max) { 47 | if (!(this->template type_check())) { 48 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 49 | return NULL_TENSOR; 50 | } 51 | 52 | tensor result(a.shape(), a.name()); 53 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 54 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 55 | auto c0 = std::bind(clipper, std::placeholders::_1, min, max); 56 | eResult.array() = eigenVector.array().unaryExpr(c0); 57 | result.load(eResult.data()); 58 | return result; 59 | } 60 | }; 61 | } // namespace dnnc 62 | -------------------------------------------------------------------------------- /src/operators/Compress.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Compress : public baseOperator { 32 | // Compress attributes 33 | public: 34 | Compress(std::string name = "opCompress") 35 | : baseOperator(opCompress, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Concat.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Concat : public baseOperator { 32 | // Concat attributes 33 | public: 34 | Concat(std::string name = "opConcat") 35 | : baseOperator(opConcat, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Constant.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Constant : public baseOperator { 32 | // Constant attributes 33 | tensor _data; 34 | 35 | public: 36 | Constant(std::string name = "opConstant", tensor data = NULL_TENSOR) 37 | : baseOperator(opConstant, name), _data(data) {} 38 | 39 | bool getAttribute(OPATTR attrName, tensor &obj) override { 40 | if (attrName == attr_value) { 41 | obj = _data; 42 | return true; 43 | } 44 | return false; 45 | } 46 | bool setAttribute(OPATTR attrName, tensor obj) override { 47 | if (attrName == attr_value) { 48 | _data = obj; 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | tensor compute(void) { return _data; } 55 | }; 56 | } // namespace dnnc 57 | -------------------------------------------------------------------------------- /src/operators/ConstantOfShape.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ConstantOfShape : public baseOperator { 32 | // ConstantOfShape attributes 33 | public: 34 | ConstantOfShape(std::string name = "opConstantOfShape") 35 | : baseOperator(opConstantOfShape, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ConvInteger.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ConvInteger : public baseOperator { 32 | // ConvInteger attributes 33 | public: 34 | ConvInteger(std::string name = "opConvInteger") 35 | : baseOperator(opConvInteger, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ConvTranspose.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ConvTranspose : public baseOperator { 32 | // ConvTranspose attributes 33 | public: 34 | ConvTranspose(std::string name = "opConvTranspose") 35 | : baseOperator(opConvTranspose, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Cos.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | #include 28 | 29 | using namespace Eigen; 30 | 31 | namespace dnnc { 32 | template class Cos : public baseOperator { 33 | // Cos attributes 34 | public: 35 | Cos(std::string name = "opCos") : baseOperator(opCos, name) {} 36 | 37 | tensor compute(tensor a) { 38 | if (!(this->template type_check())) { 39 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 40 | return NULL_TENSOR; 41 | } 42 | 43 | tensor result(a.shape(), a.name()); 44 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 45 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 46 | eResult.array() = Eigen::cos(eigenVector.array()); 47 | result.load(eResult.data()); 48 | return result; 49 | } 50 | }; 51 | } // namespace dnnc 52 | -------------------------------------------------------------------------------- /src/operators/Cosh.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | #include 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Cosh : public baseOperator { 32 | public: 33 | Cosh(std::string name = "opCosh") : baseOperator(opCosh, name) {} 34 | 35 | tensor compute(tensor a) { 36 | if (!(this->template type_check())) { 37 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 38 | return NULL_TENSOR; 39 | } 40 | 41 | tensor result(a.shape(), a.name()); 42 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 43 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 44 | eResult.array() = Eigen::cosh(eigenVector.array()); 45 | result.load(eResult.data()); 46 | return result; 47 | } 48 | }; 49 | } // namespace dnnc 50 | -------------------------------------------------------------------------------- /src/operators/CumSum.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class CumSum : public baseOperator { 32 | // CumSum attributes 33 | public: 34 | CumSum(std::string name = "opCumSum") 35 | : baseOperator(opCumSum, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/DepthToSpace.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class DepthToSpace : public baseOperator { 32 | // DepthToSpace attributes 33 | public: 34 | DepthToSpace(std::string name = "opDepthToSpace") 35 | : baseOperator(opDepthToSpace, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Erf.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | 32 | /*! Computes the error function of the given input tensor element-wise.*/ 33 | 34 | template class Erf : public baseOperator { 35 | public: 36 | Erf(std::string name = "opErf") : baseOperator(opErf, name) {} 37 | 38 | tensor compute(tensor &a /*!< : N D tensor input*/) { 39 | tensor result(a.shape(), a.name()); 40 | 41 | if (!(this->template type_check())) { 42 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 43 | return NULL_TENSOR; 44 | } 45 | 46 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 47 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 48 | 49 | eResult.array() = erf(eigenVector.array()); 50 | 51 | result.load(eResult.data()); 52 | return result; 53 | } 54 | /*!< 55 | \return The output tensor of the same shape and type as input. 56 | */ 57 | }; 58 | } // namespace dnnc 59 | -------------------------------------------------------------------------------- /src/operators/Exp.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | 32 | /*! Calculates the exponential of the given input tensor, element-wise. 33 | \f$ y = e^x \f$ */ 34 | 35 | template class Exp : public baseOperator { 36 | public: 37 | Exp(std::string name = "opExp") : baseOperator(opExp, name) {} 38 | 39 | tensor compute(tensor &a /*!< : N D tensor input*/) { 40 | 41 | if (!(this->template type_check())) { 42 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 43 | return NULL_TENSOR; 44 | } 45 | 46 | tensor result(a.shape(), a.name()); 47 | 48 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 49 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 50 | 51 | eResult.array() = exp(eigenVector.array()); 52 | 53 | result.load(eResult.data()); 54 | return result; 55 | } 56 | /*!< 57 | \return The output tensor of the same shape and type as input. 58 | */ 59 | }; 60 | } // namespace dnnc 61 | -------------------------------------------------------------------------------- /src/operators/Expand.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template 32 | class Expand : public baseOperator { 33 | 34 | public: 35 | Expand(std::string name = "opExpand") 36 | : baseOperator(opExpand, name) {} 37 | 38 | tensor compute(tensor a, tensor b) { 39 | 40 | if (!(this->template type_check())) { 41 | SPDLOG_ERROR("Constrain shape tensor to integer type."); 42 | return NULL_TENSOR; 43 | } 44 | 45 | tensor result(b.asTypeULong().data(), b.name()); 46 | tensor temp_b(b.asTypeULong().data(), b.name(), dnnc::INIT_ONE); 47 | 48 | // std::cout << a.shape()[0] << a.shape()[1] << std::endl; 49 | // std::cout << temp_b.shape()[0] << temp_b.shape()[1] << std::endl; 50 | 51 | DNNC_EIGEN_ARRAY_MAP(eigenVectorA, To, a); 52 | DNNC_EIGEN_ARRAY_MAP(eigenVectorB, To, temp_b); 53 | 54 | DNNC_EIGEN_VECTOR_CTOR(To) eResult; 55 | eResult = eigenVectorA * eigenVectorB; 56 | result.load(eResult.data()); 57 | 58 | return result; 59 | } 60 | }; 61 | } // namespace dnnc 62 | -------------------------------------------------------------------------------- /src/operators/Floor.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | 32 | /*! Floor takes one input data (Tensor) and produces one output data (Tensor) 33 | where the floor is, \f$y = floor(x)\f$ The function is applied to the tensor 34 | elementwise.*/ 35 | 36 | template class Floor : public baseOperator { 37 | public: 38 | Floor(std::string name = "opFloor") : baseOperator(opFloor, name) {} 39 | 40 | tensor compute(tensor &a /*!<[float,double]: ND tensor*/) { 41 | 42 | if (!(this->template type_check())) { 43 | SPDLOG_ERROR( 44 | "Constrain input and output types to float or double tensors."); 45 | return NULL_TENSOR; 46 | } 47 | 48 | tensor result(a.shape(), a.name()); 49 | 50 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 51 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 52 | 53 | eResult.array() = floor(eigenVector.array()); 54 | 55 | result.load(eResult.data()); 56 | return result; 57 | } 58 | /*!< 59 | \return The output tensor of the same shape and type as input. 60 | */ 61 | }; 62 | } // namespace dnnc 63 | -------------------------------------------------------------------------------- /src/operators/GRU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class GRU : public baseOperator { 32 | // GRU attributes 33 | public: 34 | GRU(std::string name = "opGRU") : baseOperator(opGRU, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Identity.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | /*! Identity operator*/ 32 | template class Identity : public baseOperator { 33 | public: 34 | Identity(std::string name = "opIdentity") 35 | : baseOperator(opIdentity, name) {} 36 | tensor compute(tensor &a /*!< Input tensor */) { return a; } 37 | /*!< 38 | \return Tensor to copy input into. 39 | */ 40 | }; 41 | } // namespace dnnc 42 | -------------------------------------------------------------------------------- /src/operators/If.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class If : public baseOperator { 32 | public: 33 | If(std::string name = "opIf") : baseOperator(opIf, name) {} 34 | 35 | void compute(void) { 36 | // CHANGE return-type and args 37 | // AND ADD YOUR FUNCTIONAL CODE HERE 38 | } 39 | }; 40 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/IsNaN.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | /*! Returns which elements of the input are NaN.*/ 32 | template 33 | class IsNaN : public baseOperator { 34 | public: 35 | IsNaN(std::string name = "opIsNaN") 36 | : baseOperator(opIsNaN, name) {} 37 | 38 | tensor compute(tensor &a) { 39 | if (!(this->template type_check())) { 40 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 41 | return NULL_TENSOR; 42 | } 43 | tensor result(a.shape(), a.name()); 44 | DNNC_EIGEN_ARRAY_MAP(eigenVector, Ti, a); 45 | DNNC_EIGEN_VECTOR_CTOR(bool) eResult; 46 | eResult.array() = eigenVector.array().isNaN(); 47 | 48 | result.load(eResult.data()); 49 | return result; 50 | } 51 | }; 52 | } // namespace dnnc 53 | -------------------------------------------------------------------------------- /src/operators/Log.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | /*! Calculates the natural logarithm of the given input tensor, element-wise. 32 | \f$ y = \ln \left ( x \right ) \f$ */ 33 | template class Log : public baseOperator { 34 | 35 | public: 36 | Log(std::string name = "opLog") : baseOperator(opLog, name) {} 37 | 38 | tensor compute(tensor a /*!<[float,double]: ND tensor*/) { 39 | 40 | if (!(this->template type_check())) { 41 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 42 | return NULL_TENSOR; 43 | } 44 | 45 | tensor result(a.shape(), a.name()); 46 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 47 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 48 | 49 | eResult.array() = log(eigenVector.array()); 50 | 51 | result.load(eResult.data()); 52 | return result; 53 | } 54 | /*!< 55 | \return The output tensor of the same shape as input. 56 | */ 57 | }; 58 | } // namespace dnnc 59 | -------------------------------------------------------------------------------- /src/operators/Loop.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Loop : public baseOperator { 32 | // Loop attributes 33 | public: 34 | Loop(std::string name = "opLoop") : baseOperator(opLoop, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc 44 | -------------------------------------------------------------------------------- /src/operators/LpPool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class LpPool : public baseOperator { 32 | // LpPool attributes 33 | public: 34 | LpPool(std::string name = "opLpPool") 35 | : baseOperator(opLpPool, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/MaxPool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class MaxPool : public baseOperator { 32 | // MaxPool attributes 33 | public: 34 | MaxPool(std::string name = "opMaxPool") 35 | : baseOperator(opMaxPool, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc 45 | -------------------------------------------------------------------------------- /src/operators/MaxRoiPool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class MaxRoiPool : public baseOperator { 32 | // MaxRoiPool attributes 33 | public: 34 | MaxRoiPool(std::string name = "opMaxRoiPool") 35 | : baseOperator(opMaxRoiPool, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/MaxUnpool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class MaxUnpool : public baseOperator { 32 | // MaxUnpool attributes 33 | public: 34 | MaxUnpool(std::string name = "opMaxUnpool") 35 | : baseOperator(opMaxUnpool, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Multinomial.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Multinomial : public baseOperator { 32 | // Multinomial attributes 33 | public: 34 | Multinomial(std::string name = "opMultinomial") 35 | : baseOperator(opMultinomial, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Neg.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Neg : public baseOperator { 32 | // Neg attributes 33 | public: 34 | Neg(std::string name = "opNeg") : baseOperator(opNeg, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | tensor compute(tensor &a /*!< ND tensor*/) { 39 | 40 | if ((this->template type_check())) { 41 | SPDLOG_ERROR("Constrain input and output types to numeric tensors."); 42 | return NULL_TENSOR; 43 | } 44 | 45 | tensor result(a.shape(), a.name()); 46 | 47 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 48 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 49 | eResult.array() = -eigenVector.array(); 50 | result.load(eResult.data()); 51 | 52 | return result; 53 | } 54 | }; 55 | } // namespace dnnc 56 | -------------------------------------------------------------------------------- /src/operators/NonMaxSuppression.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class NonMaxSuppression : public baseOperator { 32 | // NonMaxSuppression attributes 33 | public: 34 | NonMaxSuppression(std::string name = "opNonMaxSuppression") 35 | : baseOperator(opNonMaxSuppression, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/NonZero.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class NonZero : public baseOperator { 32 | // NonZero attributes 33 | public: 34 | NonZero(std::string name = "opNonZero") 35 | : baseOperator(opNonZero, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Not.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | 32 | /*! This does element wise binary not operation of given N D tensor.*/ 33 | 34 | template 35 | class Not : public baseOperator { 36 | // Not attributes 37 | public: 38 | Not(std::string name = "opNot") : baseOperator(opNot, name) {} 39 | 40 | tensor compute(tensor &a /*!< [bool]: N D tensor input*/) { 41 | 42 | // This check is for ONNX standard 43 | // if (!(this->template type_check() )) 44 | // SPDLOG_ERROR("Constrain input tensors to bool types."); 45 | 46 | tensor result(a.shape(), a.name()); 47 | 48 | DNNC_EIGEN_ARRAY_MAP(eigenVector, Ti, a); 49 | DNNC_EIGEN_VECTOR_CTOR(To) eResult; 50 | eResult.array() = !eigenVector.template cast().array(); 51 | result.load(eResult.data()); 52 | 53 | return result; 54 | } 55 | /*!< 56 | \return The output tensor of the same shape as input with dtype bool. 57 | */ 58 | }; 59 | } // namespace dnnc 60 | -------------------------------------------------------------------------------- /src/operators/Pad.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Pad : public baseOperator { 32 | // Pad attributes 33 | std::string mode; 34 | 35 | public: 36 | Pad(std::string name = "opPad", std::string mode = "constant") 37 | : baseOperator(opPad, name) {} 38 | 39 | // bool getAttribute(OPATTR attrName, int& obj) ; 40 | bool getAttribute(OPATTR attrName, std::string &obj) override { 41 | if (attrName == attr_mode) { 42 | obj = mode; 43 | return true; 44 | } 45 | return false; 46 | } 47 | bool setAttribute(OPATTR attrName, std::string obj) override { 48 | if (attrName == attr_mode) { 49 | mode = obj; 50 | return true; 51 | } 52 | return false; 53 | } 54 | 55 | tensor compute(tensor &x, tensor &pads, T constant_value = 0) { 56 | // CHANGE return-type and args 57 | // AND ADD YOUR FUNCTIONAL CODE HERE 58 | } 59 | }; 60 | } // namespace dnnc 61 | -------------------------------------------------------------------------------- /src/operators/QLinearConv.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class QLinearConv : public baseOperator { 32 | // QLinearConv attributes 33 | public: 34 | QLinearConv(std::string name = "opQLinearConv") 35 | : baseOperator(opQLinearConv, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/QLinearMatMul.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class QLinearMatMul : public baseOperator { 32 | // QLinearMatMul attributes 33 | public: 34 | QLinearMatMul(std::string name = "opQLinearMatMul") 35 | : baseOperator(opQLinearMatMul, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/QuantizeLinear.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class QuantizeLinear : public baseOperator { 32 | // QuantizeLinear attributes 33 | public: 34 | QuantizeLinear(std::string name = "opQuantizeLinear") 35 | : baseOperator(opQuantizeLinear, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/RNN.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class RNN : public baseOperator { 32 | // RNN attributes 33 | public: 34 | RNN(std::string name = "opRNN") : baseOperator(opRNN, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/RandomNormal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class RandomNormal : public baseOperator { 32 | // RandomNormal attributes 33 | public: 34 | RandomNormal(std::string name = "opRandomNormal") 35 | : baseOperator(opRandomNormal, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/RandomNormalLike.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class RandomNormalLike : public baseOperator { 32 | // RandomNormalLike attributes 33 | public: 34 | RandomNormalLike(std::string name = "opRandomNormalLike") 35 | : baseOperator(opRandomNormalLike, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/RandomUniform.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class RandomUniform : public baseOperator { 32 | // RandomUniform attributes 33 | public: 34 | RandomUniform(std::string name = "opRandomUniform") 35 | : baseOperator(opRandomUniform, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/RandomUniformLike.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class RandomUniformLike : public baseOperator { 32 | // RandomUniformLike attributes 33 | public: 34 | RandomUniformLike(std::string name = "opRandomUniformLike") 35 | : baseOperator(opRandomUniformLike, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Reciprocal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Reciprocal : public baseOperator { 32 | // Reciprocal attributes 33 | public: 34 | Reciprocal(std::string name = "opReciprocal") 35 | : baseOperator(opReciprocal, name) {} 36 | 37 | static T reciprocal_function(T x) { return (x > 0) ? (1 / x) : x; } 38 | 39 | // bool getAttribute(OPATTR attrName, int& obj) ; 40 | 41 | tensor compute(tensor &a) { 42 | if (!(this->template type_check())) { 43 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 44 | return NULL_TENSOR; 45 | } 46 | 47 | tensor result(a.shape()); 48 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 49 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 50 | 51 | // eResult.array() = eigenVector.array().unaryExpr(reciprocal_function); 52 | eResult.array() = eigenVector.array().inverse(); 53 | result.load(eResult.data()); 54 | 55 | return result; 56 | // CHANGE return-type and args 57 | // AND ADD YOUR FUNCTIONAL CODE HERE 58 | } 59 | }; 60 | } // namespace dnnc 61 | -------------------------------------------------------------------------------- /src/operators/ReduceL1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceL1 : public baseOperator { 32 | // ReduceL1 attributes 33 | public: 34 | ReduceL1(std::string name = "opReduceL1") 35 | : baseOperator(opReduceL1, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReduceL2.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceL2 : public baseOperator { 32 | // ReduceL2 attributes 33 | public: 34 | ReduceL2(std::string name = "opReduceL2") 35 | : baseOperator(opReduceL2, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReduceLogSum.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceLogSum : public baseOperator { 32 | // ReduceLogSum attributes 33 | public: 34 | ReduceLogSum(std::string name = "opReduceLogSum") 35 | : baseOperator(opReduceLogSum, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReduceLogSumExp.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceLogSumExp : public baseOperator { 32 | // ReduceLogSumExp attributes 33 | public: 34 | ReduceLogSumExp(std::string name = "opReduceLogSumExp") 35 | : baseOperator(opReduceLogSumExp, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReduceMax.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceMax : public baseOperator { 32 | // ReduceMax attributes 33 | public: 34 | ReduceMax(std::string name = "opReduceMax") 35 | : baseOperator(opReduceMax, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReduceMean.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceMean : public baseOperator { 32 | // ReduceMean attributes 33 | public: 34 | ReduceMean(std::string name = "opReduceMean") 35 | : baseOperator(opReduceMean, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReduceMin.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceMin : public baseOperator { 32 | // ReduceMin attributes 33 | public: 34 | ReduceMin(std::string name = "opReduceMin") 35 | : baseOperator(opReduceMin, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReduceProd.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReduceProd : public baseOperator { 32 | // ReduceProd attributes 33 | public: 34 | ReduceProd(std::string name = "opReduceProd") 35 | : baseOperator(opReduceProd, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Relu.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template 32 | class Relu : public baseOperator { 33 | // Relu attributes 34 | static Ti relu_func(Ti x) { 35 | Ti zero = 0; 36 | return x < zero ? zero : x; 37 | } 38 | 39 | public: 40 | Relu(std::string name = "opRelu") : baseOperator(opRelu, name) {} 41 | 42 | tensor compute(tensor &input) { 43 | if (!(this->template type_check())) { 44 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 45 | return NULL_TENSOR; 46 | } 47 | 48 | tensor result(input.shape(), input.name()); 49 | DNNC_EIGEN_ARRAY_MAP(eigenVector, Ti, input); 50 | DNNC_EIGEN_VECTOR_CTOR(Ti) eResult; 51 | eResult.array() = eigenVector.array().unaryExpr(&relu_func); 52 | result.load(eResult.data()); 53 | 54 | return result.template asType(); 55 | } 56 | }; 57 | } // namespace dnnc 58 | -------------------------------------------------------------------------------- /src/operators/Resize.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Resize : public baseOperator { 32 | // Resize attributes 33 | public: 34 | Resize(std::string name = "opResize") 35 | : baseOperator(opResize, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ReverseSequence.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class ReverseSequence : public baseOperator { 32 | // ReverseSequence attributes 33 | public: 34 | ReverseSequence(std::string name = "opReverseSequence") 35 | : baseOperator(opReverseSequence, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/RoiAlign.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class RoiAlign : public baseOperator { 32 | // RoiAlign attributes 33 | public: 34 | RoiAlign(std::string name = "opRoiAlign") 35 | : baseOperator(opRoiAlign, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Round.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Round : public baseOperator { 32 | // Round attributes 33 | public: 34 | Round(std::string name = "opRound") : baseOperator(opRound, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Scan.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Scan : public baseOperator { 32 | // Scan attributes 33 | public: 34 | Scan(std::string name = "opScan") : baseOperator(opScan, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Scatter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Scatter : public baseOperator { 32 | // Scatter attributes 33 | public: 34 | Scatter(std::string name = "opScatter") 35 | : baseOperator(opScatter, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Selu.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Selu : public baseOperator { 32 | // Selu attributes 33 | public: 34 | Selu(std::string name = "opSelu") : baseOperator(opSelu, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Shape.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Shape : public baseOperator { 32 | // Shape attributes 33 | public: 34 | Shape(std::string name = "opShape") : baseOperator(opShape, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Shrink.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Shrink : public baseOperator { 32 | // Shrink attributes 33 | public: 34 | Shrink(std::string name = "opShrink") 35 | : baseOperator(opShrink, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Sign.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | #pragma once 24 | #include "operators/baseOperator.h" 25 | #include 26 | 27 | using namespace Eigen; 28 | 29 | namespace dnnc { 30 | /*! Returns the tensor resulted from performing the sign operation 31 | * elementwise on the input tensor A . 32 | */ 33 | template class Sign : public baseOperator { 34 | protected: 35 | public: 36 | Sign(std::string name = "opSign") : baseOperator(opSign, name) {} 37 | 38 | // NOT GOOD to return by value 39 | tensor compute(tensor &a /*!< : Input operand([float,double]: ND tensor) for the Sign operator.*/) { 40 | if (!(this->template type_check())) { 41 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 42 | return NULL_TENSOR; 43 | } 44 | 45 | tensor result(a.shape(), a.name()); 46 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 47 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 48 | eResult.array() = sign(eigenVector.array()); 49 | result.load(eResult.data()); 50 | return result; 51 | } 52 | }; 53 | } // namespace dnnc 54 | -------------------------------------------------------------------------------- /src/operators/Sin.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | #pragma once 24 | #include "operators/baseOperator.h" 25 | #include 26 | 27 | using namespace Eigen; 28 | 29 | namespace dnnc { 30 | /*! Returns the tensor resulted from performing the sin operation \f$ h(x) = 31 | * \sin(x) \f$ elementwise on the input tensor A . 32 | */ 33 | template class Sin : public baseOperator { 34 | protected: 35 | public: 36 | Sin(std::string name = "opSin") : baseOperator(opSin, name) {} 37 | 38 | // NOT GOOD to return by value 39 | tensor compute(tensor &a /*!< : Input operand([float,double]: ND tensor) for the Sin operator.*/) { 40 | 41 | if (!(this->template type_check())) { 42 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 43 | return NULL_TENSOR; 44 | } 45 | 46 | tensor result(a.shape(), a.name()); 47 | 48 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 49 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 50 | 51 | eResult.array() = sin(eigenVector.array()); 52 | 53 | result.load(eResult.data()); 54 | return result; 55 | } 56 | }; 57 | } // namespace dnnc 58 | -------------------------------------------------------------------------------- /src/operators/Sinh.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | #pragma once 24 | #include "operators/baseOperator.h" 25 | #include 26 | 27 | using namespace Eigen; 28 | 29 | namespace dnnc { 30 | /*! Returns the tensor resulted from performing the sin operation \f$ h(x) = 31 | * \sinh(x) \f$ elementwise on the input tensor A . 32 | */ 33 | template class Sinh : public baseOperator { 34 | protected: 35 | public: 36 | Sinh(std::string name = "opSinh") : baseOperator(opSinh, name) {} 37 | 38 | // NOT GOOD to return by value 39 | tensor compute(tensor &a /*!< : Input operand([float,double]: ND tensor) for the Sinh operator.*/) { 40 | 41 | if (!(this->template type_check())) { 42 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 43 | return NULL_TENSOR; 44 | } 45 | 46 | tensor result(a.shape(), a.name()); 47 | 48 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 49 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 50 | 51 | eResult.array() = sinh(eigenVector.array()); 52 | 53 | result.load(eResult.data()); 54 | return result; 55 | } 56 | }; 57 | } // namespace dnnc 58 | -------------------------------------------------------------------------------- /src/operators/Size.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Size : public baseOperator { 32 | // Size attributes 33 | public: 34 | Size(std::string name = "opSize") : baseOperator(opSize, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Softplus.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | #pragma once 24 | #include "operators/baseOperator.h" 25 | #include 26 | 27 | using namespace Eigen; 28 | namespace dnnc { 29 | /*! Returns the tensor resulted from performing the sigmoid operation \f$ h(x) = 30 | * \log({\mathrm{1} + e^x }) \f$ elementwise on the input tensor A . 31 | */ 32 | 33 | template class Softplus : public baseOperator { 34 | protected: 35 | public: 36 | Softplus(std::string name = "opSoftplus") 37 | : baseOperator(opSoftplus, name) {} 38 | 39 | static T softplus_func(T x) { return log(1 + exp(x)); } 40 | 41 | // NOT GOOD to return by value 42 | tensor compute(tensor &a /*!< : Input operand([float,double]: ND tensor) for the Softplus operator.*/) { 43 | 44 | if (!(this->template type_check())) { 45 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 46 | return NULL_TENSOR; 47 | } 48 | 49 | tensor result(a.shape(), a.name()); 50 | 51 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 52 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 53 | 54 | eResult.array() = eigenVector.array().unaryExpr(&softplus_func); 55 | 56 | result.load(eResult.data()); 57 | return result; 58 | } 59 | }; 60 | } // namespace dnnc 61 | -------------------------------------------------------------------------------- /src/operators/SpaceToDepth.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class SpaceToDepth : public baseOperator { 32 | // SpaceToDepth attributes 33 | public: 34 | SpaceToDepth(std::string name = "opSpaceToDepth") 35 | : baseOperator(opSpaceToDepth, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Split.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Split : public baseOperator { 32 | // Split attributes 33 | public: 34 | Split(std::string name = "opSplit") : baseOperator(opSplit, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Sqrt.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | #pragma once 24 | #include "operators/baseOperator.h" 25 | #include 26 | 27 | using namespace Eigen; 28 | 29 | namespace dnnc { 30 | /*! Returns the tensor resulted from performing the sin operation \f$ h(x) = 31 | * \sqrt x \f$ elementwise on the input tensor A . 32 | */ 33 | template class Sqrt : public baseOperator { 34 | protected: 35 | public: 36 | Sqrt(std::string name = "opSqrt") : baseOperator(opSqrt, name) {} 37 | 38 | // NOT GOOD to return by value 39 | tensor compute(tensor &a /*!< : Input operand([float,double]: ND tensor) for the Sqrt operator.*/) { 40 | if (!(this->template type_check())) { 41 | SPDLOG_ERROR("Constrain input and output types to float tensors."); 42 | return NULL_TENSOR; 43 | } 44 | 45 | tensor result(a.shape(), a.name()); 46 | 47 | DNNC_EIGEN_ARRAY_MAP(eigenVector, T, a); 48 | DNNC_EIGEN_VECTOR_CTOR(T) eResult; 49 | 50 | eResult.array() = sqrt(eigenVector.array()); 51 | 52 | result.load(eResult.data()); 53 | return result; 54 | } 55 | }; 56 | } // namespace dnnc 57 | -------------------------------------------------------------------------------- /src/operators/Squeeze.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Squeeze : public baseOperator { 32 | // Squeeze attributes 33 | public: 34 | Squeeze(std::string name = "opSqueeze") 35 | : baseOperator(opSqueeze, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/StringNormalizer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class StringNormalizer : public baseOperator { 32 | // StringNormalizer attributes 33 | public: 34 | StringNormalizer(std::string name = "opStringNormalizer") 35 | : baseOperator(opStringNormalizer, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Sum.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Sum : public baseOperator { 32 | // Sum attributes 33 | public: 34 | Sum(std::string name = "opSum") : baseOperator(opSum, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/TfIdfVectorizer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class TfIdfVectorizer : public baseOperator { 32 | // TfIdfVectorizer attributes 33 | public: 34 | TfIdfVectorizer(std::string name = "opTfIdfVectorizer") 35 | : baseOperator(opTfIdfVectorizer, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/ThresholdedRelu.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template 32 | class ThresholdedRelu : public baseOperator { 33 | // ThresholdedRelu attributes 34 | float alpha = 1.0; // alpha's default value. 35 | public: 36 | ThresholdedRelu(std::string name = "opThresholdedRelu") 37 | : baseOperator(opThresholdedRelu, name) {} 38 | 39 | bool getAttribute(OPATTR attrName, float &obj) override { 40 | if (attrName == attr_alpha) { 41 | obj = alpha; 42 | return true; 43 | } 44 | return false; 45 | } 46 | bool setAttribute(OPATTR attrName, float obj) override { 47 | if (attrName == attr_alpha) { 48 | alpha = obj; 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | tensor compute(tensor &input) { 55 | // create a new copy of input. 56 | tensor result(input.shape(), input.name()); 57 | for (size_t i = 0; i < input.length(); i++) 58 | result[i] = input[i] > alpha ? input[i] : 0.0; 59 | 60 | return result; 61 | } 62 | }; 63 | } // namespace dnnc 64 | -------------------------------------------------------------------------------- /src/operators/Tile.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Tile : public baseOperator { 32 | // Tile attributes 33 | public: 34 | Tile(std::string name = "opTile") : baseOperator(opTile, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/TopK.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class TopK : public baseOperator { 32 | // TopK attributes 33 | public: 34 | TopK(std::string name = "opTopK") : baseOperator(opTopK, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | void compute(void) { 39 | // CHANGE return-type and args 40 | // AND ADD YOUR FUNCTIONAL CODE HERE 41 | } 42 | }; 43 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Unsqueeze.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Unsqueeze : public baseOperator { 32 | // Unsqueeze attributes 33 | public: 34 | Unsqueeze(std::string name = "opUnsqueeze") 35 | : baseOperator(opUnsqueeze, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Upsample.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Upsample : public baseOperator { 32 | // Upsample attributes 33 | public: 34 | Upsample(std::string name = "opUpsample") 35 | : baseOperator(opUpsample, name) {} 36 | 37 | // bool getAttribute(OPATTR attrName, int& obj) ; 38 | 39 | void compute(void) { 40 | // CHANGE return-type and args 41 | // AND ADD YOUR FUNCTIONAL CODE HERE 42 | } 43 | }; 44 | } // namespace dnnc -------------------------------------------------------------------------------- /src/operators/Where.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The AITS DNNC Authors.All Rights Reserved. 2 | // 3 | // Licensed to the Apache Software Foundation(ASF) under one 4 | // or more contributor license agreements.See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership.The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License.You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, 14 | // software distributed under the License is distributed on an 15 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied.See the License for the 17 | // specific language governing permissionsand limitations 18 | // under the License. 19 | // 20 | // This file is part of AITS DNN compiler maintained at 21 | // https://github.com/ai-techsystems/dnnCompiler 22 | // 23 | 24 | #pragma once 25 | #include "operators/baseOperator.h" 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | namespace dnnc { 31 | template class Where : public baseOperator { 32 | // Where attributes 33 | public: 34 | Where(std::string name = "opWhere") : baseOperator(opWhere, name) {} 35 | 36 | // bool getAttribute(OPATTR attrName, int& obj) ; 37 | 38 | tensor compute(tensor &B, tensor &X, tensor &Y) { 39 | 40 | if (X.shape() != Y.shape() || X.shape() != B.shape() || 41 | Y.shape() != B.shape()) { 42 | SPDLOG_ERROR("tensor dimenions not appropriate for Where operator."); 43 | return NULL_TENSOR; 44 | } 45 | 46 | tensor result(X.shape(), X.name()); 47 | for (size_t i = 0; i < X.length(); i++) 48 | result[i] = B[i] ? X[i] : Y[i]; 49 | 50 | return result; 51 | } 52 | }; 53 | } // namespace dnnc 54 | --------------------------------------------------------------------------------