diff --git a/CMakeLists.txt b/CMakeLists.txt index d3cbc8442..f2c6ca31f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 3.9.2) # User options option(BUILD_SUPERBUILD "Compile using the superbuild system" OFF) +option(BUILD_RISCV "Compile for a RISCV cpu" OFF) option(BUILD_PROTOBUF "Compile using Protobuf" ON) option(BUILD_OPENMP "Compile using OpenMP" ON) option(BUILD_HPC "Compile using aggressive flags for performance" ON) @@ -194,4 +195,4 @@ endif() if(BUILD_TESTS AND BUILD_HPC) message(WARNING "[WARNING] Some logic functions are not compatible with the 'BUILD_HPC' flag. If you're unit testing, or using one of these logic functions: isfinite(), isinf(), isnan(), isposinf(), isneginf(); then we recommend you to disable the HPC flag: '-D BUILD_HPC=OFF' to obtain the expected results.") -endif() \ No newline at end of file +endif() diff --git a/Jenkinsfile b/Jenkinsfile index 6f0d6600f..b9939acb3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { agent { docker { label 'docker' - image 'pritt/base' + image 'aimagelab/base' } } stages { @@ -15,7 +15,7 @@ pipeline { steps { timeout(60) { echo 'Building..' - cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=CPU -DBUILD_SUPERBUILD=ON -DBUILD_TESTS=ON', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ + cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=CPU -DBUILD_SUPERBUILD=ON -DBUILD_TESTS=ON -DBUILD_HPC=OFF -DBUILD_DIST=OFF -DBUILD_RUNTIME=OFF', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ [args: '--parallel 4', withCmake: true] ] } @@ -45,7 +45,7 @@ pipeline { steps { timeout(60) { echo 'Building..' - cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=CPU -DBUILD_SHARED_LIBS=OFF -DBUILD_SUPERBUILD=ON -DBUILD_TESTS=ON', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ + cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=CPU -DBUILD_SHARED_LIBS=OFF -DBUILD_SUPERBUILD=ON -DBUILD_TESTS=ON -DBUILD_HPC=OFF -DBUILD_DIST=OFF -DBUILD_RUNTIME=OFF', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ [args: '--config Release --parallel 4', withCmake: true] ] } @@ -70,7 +70,7 @@ pipeline { agent { docker { label 'docker && gpu' - image 'pritt/base-cuda' + image 'aimagelab/base-cuda' args '--gpus 1' } } @@ -79,7 +79,7 @@ pipeline { steps { timeout(60) { echo 'Building..' - cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=GPU -DBUILD_TESTS=ON -DBUILD_SUPERBUILD=ON', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ + cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=GPU -DBUILD_TESTS=ON -DBUILD_SUPERBUILD=ON -DBUILD_HPC=OFF -DBUILD_DIST=OFF -DBUILD_RUNTIME=OFF', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ [args: '--parallel 4', withCmake: true] ] } @@ -109,7 +109,7 @@ pipeline { steps { timeout(60) { echo 'Building..' - cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=GPU -DBUILD_TESTS=ON -DBUILD_SUPERBUILD=ON', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ + cmakeBuild buildDir: 'build', buildType: 'Release', cmakeArgs: '-DBUILD_TARGET=GPU -DBUILD_TESTS=ON -DBUILD_SUPERBUILD=ON -DBUILD_HPC=OFF -DBUILD_DIST=OFF -DBUILD_RUNTIME=OFF', installation: 'InSearchPath', sourceDir: '.', cleanBuild: true, steps: [ [args: '--config Release --parallel 4', withCmake: true] ] } diff --git a/cmake/googletest.CMakeLists.txt.in b/cmake/googletest.CMakeLists.txt.in index f8dddee7c..6b2645b75 100644 --- a/cmake/googletest.CMakeLists.txt.in +++ b/cmake/googletest.CMakeLists.txt.in @@ -10,7 +10,7 @@ include(ExternalProject) ExternalProject_Add(googletest PREFIX googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG "release-1.10.0" + GIT_TAG "release-1.11.0" SOURCE_DIR "${EP_BASE_DIR}/googletest-src" BINARY_DIR "${EP_BASE_DIR}/googletest-build" CMAKE_CACHE_ARGS diff --git a/examples/nn/1_mnist/1_mnist_mlp.cpp b/examples/nn/1_mnist/1_mnist_mlp.cpp index 17475e7d9..97134a481 100644 --- a/examples/nn/1_mnist/1_mnist_mlp.cpp +++ b/examples/nn/1_mnist/1_mnist_mlp.cpp @@ -36,7 +36,7 @@ int main(int argc, char **argv) { // Settings int epochs = (testing) ? 2 : 10; - int batch_size = 200; + int batch_size = 100; int num_classes = 10; // Define network diff --git a/examples/nn/1_mnist/7_mnist_conv.cpp b/examples/nn/1_mnist/7_mnist_conv.cpp index 754be9a07..3d02de43a 100644 --- a/examples/nn/1_mnist/7_mnist_conv.cpp +++ b/examples/nn/1_mnist/7_mnist_conv.cpp @@ -23,20 +23,33 @@ using namespace eddl; ////////////////////////////////// int main(int argc, char **argv) { + + // Settings + int epochs = 10; + int batch_size = 100; + int num_classes = 10; bool testing = false; bool use_cpu = false; + int num_cpu_threads = -1; // -1 = the maximum available cores + for (int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "--testing") == 0) testing = true; - else if (strcmp(argv[i], "--cpu") == 0) use_cpu = true; + if (strcmp(argv[i], "--testing") == 0) { + testing = true; + epochs = 2; + } else if (strcmp(argv[i], "--cpu") == 0) { + use_cpu = true; + } else if (strcmp(argv[i], "--threads") == 0) { + num_cpu_threads = atoi(argv[++i]); + } else if (strcmp(argv[i], "--epochs") == 0) { + epochs = atoi(argv[++i]); + } else if (strcmp(argv[i], "--batch-size") == 0) { + batch_size = atoi(argv[++i]); + } } // Download mnist download_mnist(); - // Settings - int epochs = (testing) ? 2 : 10; - int batch_size = 100; - int num_classes = 10; // Define network layer in = Input({784}); @@ -62,7 +75,7 @@ int main(int argc, char **argv) { compserv cs = nullptr; if (use_cpu) { - cs = CS_CPU(); + cs = CS_CPU(num_cpu_threads); } else { cs = CS_GPU({1}, "full_mem"); // one GPU // cs = CS_GPU({1,1},100); // two GPU with weight sync every 100 batches diff --git a/formulas/brew/eddl.rb b/formulas/brew/eddl.rb index 9391ddd07..5fd87bf68 100644 --- a/formulas/brew/eddl.rb +++ b/formulas/brew/eddl.rb @@ -4,8 +4,8 @@ class Eddl < Formula desc "European Distributed Deep Learning Library (EDDL)" homepage "https://github.com/deephealthproject/eddl" - url "https://github.com/deephealthproject/eddl/archive/v1.0.2a.tar.gz" - sha256 "70d6067d44cb547e218236e5bb72faf45f602a7b8214f869626ca47f241481a0" + url "https://github.com/deephealthproject/eddl/archive/v1.1b.tar.gz" + sha256 "b9fe2bdc63808ae8e1a8eec96f66106c49b7a5ce9ee32ffe17fd6cf9d1b2c4ec" depends_on "cmake" => :build depends_on "eigen" => :build diff --git a/formulas/conda/eddl/build.sh b/formulas/conda/eddl/build.sh index 4a6bf47c1..82a98d544 100644 --- a/formulas/conda/eddl/build.sh +++ b/formulas/conda/eddl/build.sh @@ -30,7 +30,7 @@ echo "CPU_COUNT=$CPU_COUNT" echo "#################################################" # Build makefiles -mkdir build && cd build/ && cmake .. -DBUILD_TARGET=CPU \ +mkdir build && cd build/ && cmake .. -DBUILD_TARGET=CUDNN \ -DBUILD_SUPERBUILD=OFF \ -DBUILD_EXAMPLES=OFF \ -DBUILD_TESTS=OFF \ diff --git a/formulas/conda/eddl/meta.yaml b/formulas/conda/eddl/meta.yaml index 71c5f99d9..4c59c6777 100644 --- a/formulas/conda/eddl/meta.yaml +++ b/formulas/conda/eddl/meta.yaml @@ -1,6 +1,6 @@ -{% set name = "eddl-cpu" %} # eddl-cpu, eddl-gpu, eddl-cudnn +{% set name = "eddl-cudnn" %} # eddl-cpu, eddl-gpu, eddl-cudnn {% set version = "1.1b" %} -{% set sha256 = "534ca4bd5e83236c164a26a058e08df971d28c0ae5b32674bec364ae0370843a" %} +{% set sha256 = "b9fe2bdc63808ae8e1a8eec96f66106c49b7a5ce9ee32ffe17fd6cf9d1b2c4ec" %} package: name: {{ name|lower }} diff --git a/scripts/install/install_gtest.sh b/scripts/install/install_gtest.sh index e968ec7ce..7cfbb2538 100755 --- a/scripts/install/install_gtest.sh +++ b/scripts/install/install_gtest.sh @@ -5,9 +5,12 @@ sudo apt-get update sudo apt-get wget # Build and install -wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz -tar -zxvf release-1.10.0.tar.gz -cd googletest-release-1.10.0 && mkdir build && \ +#wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz +#tar -zxvf release-1.10.0.tar.gz +#cd googletest-release-1.10.0 && mkdir build && \ +wget https://github.com/google/googletest/archive/release-1.11.0.tar.gz +tar -zxvf release-1.11.0.tar.gz +cd googletest-release-1.11.0 && mkdir build && \ cd build && cmake .. && sudo make -j$(nproc) install # Build and install @@ -15,4 +18,4 @@ cd build && cmake .. && sudo make -j$(nproc) install #cd /usr/src/gtest #cmake CMakeLists.txt #make -j$(nproc) -#cp *.a /usr/lib \ No newline at end of file +#cp *.a /usr/lib diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f2129da9..27d85610f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ set_property(CACHE BUILD_TARGET PROPERTY STRINGS CPU GPU CUDNN FPGA) # Initializations (Local's scope) SET(USE_OPENMP OFF) +SET(USE_RISCV OFF) SET(USE_CUDA OFF) SET(USE_CUDNN OFF) SET(USE_FPGA OFF) @@ -20,6 +21,8 @@ SET(USE_PROTOBUF OFF) # Device specific setup string(TOUPPER ${BUILD_TARGET} BUILD_TARGET) # Detect cpu, Cpu, CPU,... if(${BUILD_TARGET} STREQUAL "CPU") +elseif(${BUILD_TARGET} STREQUAL "RISCV") + SET(USE_RISCV ON) # Local's scope elseif(${BUILD_TARGET} STREQUAL "GPU" OR ${BUILD_TARGET} STREQUAL "CUDA") SET(USE_CUDA ON) # Local's scope elseif(${BUILD_TARGET} STREQUAL "CUDNN") @@ -122,6 +125,11 @@ endif() ########################## COMPILE FOR RISK-V ############################# ########################################################################### +if(USE_RISCV) + set(CMAKE_C_FLAGS_RELEASE "-O2 -march=rv64imafdc -mabi=lp64d ") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -march=rv64imafdc -mabi=lp64d ") +endif() + if(RISKV_COMPILER_PATH) message(STATUS "Compiling for Risk-V...") endif() @@ -499,10 +507,8 @@ if(USE_FPGA) message(STATUS "OpenCL include: " ${OpenCL_INCLUDE_DIRS} ) message(STATUS "OpenCL libraries: " ${OpenCL_LIBRARIES} ) endif() -if(RISKV_COMPILER_PATH) - message(STATUS "-------------------------------------------" ) - message(STATUS "Risk-V compiler: " ${RISKV_COMPILER_PATH} ) -endif() +message(STATUS "-------------------------------------------" ) +message(STATUS "RISCV enabled: " ${USE_RISCV} ) message(STATUS "-------------------------------------------" ) message(STATUS "Eigen3 root dir: " ${Eigen3_DIR} ) message(STATUS "Eigen3 include: " ${EIGEN3_INCLUDE_DIR} ) diff --git a/src/descriptors/descriptor_conv2D.cpp b/src/descriptors/descriptor_conv2D.cpp index bd934b4dd..9879d4c7f 100644 --- a/src/descriptors/descriptor_conv2D.cpp +++ b/src/descriptors/descriptor_conv2D.cpp @@ -77,6 +77,9 @@ ConvolDescriptor::~ConvolDescriptor(){ delete gpuOB; } } +#else + cudnnDestroyTensorDescriptor(xDesc); + cudnnDestroyTensorDescriptor(yDesc); #endif #endif @@ -219,8 +222,7 @@ void ConvolDescriptor::build(Tensor *A) { convolution_mode, data_type); cudnnCreateTensorDescriptor(&xDesc); - cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, - in,iz,ir,ic); + cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, in,iz,ir,ic); cudnnCreateFilterDescriptor(&wDesc); cudnnSetFilter4dDescriptor(wDesc, data_type, tensor_format, nk, kz, kr, kc); @@ -264,11 +266,15 @@ void ConvolDescriptor::resize(int b) #endif #ifdef cCUDNN - cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, - b,iz,ir,ic); + cudnnDestroyTensorDescriptor(xDesc); + cudnnDestroyTensorDescriptor(yDesc); + cudnnCreateTensorDescriptor(&xDesc); cudnnCreateTensorDescriptor(&yDesc); - cudnnSetTensor4dDescriptor(yDesc, tensor_format, data_type, O->shape[0], O->shape[1],O->shape[2],O->shape[3]); + + cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, b,iz,ir,ic); + cudnnSetTensor4dDescriptor(yDesc, tensor_format, data_type, b, O->shape[1],O->shape[2],O->shape[3]); + cudnn_env_init = -1; cudnn_conv_back_init = -1; diff --git a/src/descriptors/descriptor_conv3D.cpp b/src/descriptors/descriptor_conv3D.cpp index 5c81fdfae..73c65f90f 100644 --- a/src/descriptors/descriptor_conv3D.cpp +++ b/src/descriptors/descriptor_conv3D.cpp @@ -293,15 +293,19 @@ void ConvolDescriptor3D::resize(int b) #endif #ifdef cCUDNN + cudnnDestroyTensorDescriptor(xDesc); + cudnnDestroyTensorDescriptor(yDesc); + + cudnnCreateTensorDescriptor(&xDesc); + cudnnCreateTensorDescriptor(&yDesc); + int dims[5] = {b, iz, id, ir, ic}; int str[5] = {iz*id*ir*ic,id*ir*ic,ir*ic,ic,1}; - cudnnSetTensorNdDescriptor(xDesc, /*tensor_format,*/ data_type,5,dims,str); + cudnnSetTensorNdDescriptor(xDesc, /*tensor_format,*/ data_type,5,dims,str); int ydims[5] = {b,z,d,r,c}; int ystr[5] = {z*d*r*c, d*r*c, r*c, c, 1}; - cudnnSetTensorNdDescriptor(yDesc, /*tensor_format,*/ data_type, 5, ydims, ystr); - - //cudnnSetTensor4dDescriptor(yDesc, tensor_format, data_type, O->shape[0], O->shape[1],O->shape[2],O->shape[3]); + cudnnSetTensorNdDescriptor(yDesc, /*tensor_format,*/ data_type, 5, ydims, ystr); cudnn_env_init = -1; cudnn_conv_back_init = -1; diff --git a/src/descriptors/descriptor_pool2D.cpp b/src/descriptors/descriptor_pool2D.cpp index edc130b36..e9d9f43a2 100644 --- a/src/descriptors/descriptor_pool2D.cpp +++ b/src/descriptors/descriptor_pool2D.cpp @@ -131,8 +131,7 @@ void PoolDescriptor::build(Tensor *A) { tensor_format = CUDNN_TENSOR_NCHW; // CUDNN_TENSOR_NHWC cudnnCreateTensorDescriptor(&xDesc); - cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, - in,iz,ir,ic); + cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, in,iz,ir,ic); cudnnCreateTensorDescriptor(&yDesc); cudnnSetTensor4dDescriptor(yDesc, tensor_format, data_type, in, z,r,c); } @@ -146,10 +145,14 @@ void PoolDescriptor::resize(int b) { this->O->resize(b); #ifdef cCUDNN if(!this->O->isCPU()){ - cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, - b,iz,ir,ic); - cudnnCreateTensorDescriptor(&yDesc); - cudnnSetTensor4dDescriptor(yDesc, tensor_format, data_type, O->shape[0], O->shape[1],O->shape[2],O->shape[3]); + cudnnDestroyTensorDescriptor(xDesc); + cudnnDestroyTensorDescriptor(yDesc); + + cudnnCreateTensorDescriptor(&xDesc); + cudnnCreateTensorDescriptor(&yDesc); + + cudnnSetTensor4dDescriptor(xDesc, tensor_format, data_type, b,iz,ir,ic); + cudnnSetTensor4dDescriptor(yDesc, tensor_format, data_type, b, O->shape[1],O->shape[2],O->shape[3]); } #endif // if (!mem_level) { D->resize(b); } diff --git a/src/descriptors/descriptor_pool3D.cpp b/src/descriptors/descriptor_pool3D.cpp index a737908b7..2cebb4762 100644 --- a/src/descriptors/descriptor_pool3D.cpp +++ b/src/descriptors/descriptor_pool3D.cpp @@ -167,14 +167,19 @@ void PoolDescriptor3D::resize(int b) { O->resize(b); #ifdef cCUDNN if(!O->isCPU()){ - int dims[5] = {b, iz, id, ir, ic}; - int str[5] = {iz*id*ir*ic,id*ir*ic,ir*ic,ic,1}; - cudnnSetTensorNdDescriptor(xDesc, data_type,5,dims,str); + cudnnDestroyTensorDescriptor(xDesc); + cudnnDestroyTensorDescriptor(yDesc); - int ydims[5] = {b,z,d,r,c}; - int ystr[5] = {z*d*r*c, d*r*c, r*c, c, 1}; - cudnnSetTensorNdDescriptor(yDesc, data_type, 5, ydims, ystr); + cudnnCreateTensorDescriptor(&xDesc); + cudnnCreateTensorDescriptor(&yDesc); + + int dims[5] = {b, iz, id, ir, ic}; + int str[5] = {iz*id*ir*ic,id*ir*ic,ir*ic,ic,1}; + cudnnSetTensorNdDescriptor(xDesc, data_type,5,dims,str); + int ydims[5] = {b,z,d,r,c}; + int ystr[5] = {z*d*r*c, d*r*c, r*c, c, 1}; + cudnnSetTensorNdDescriptor(yDesc, data_type, 5, ydims, ystr); } diff --git a/src/layers/conv/layer_conv1D.cpp b/src/layers/conv/layer_conv1D.cpp index b4449433f..369d8d1dc 100644 --- a/src/layers/conv/layer_conv1D.cpp +++ b/src/layers/conv/layer_conv1D.cpp @@ -112,6 +112,8 @@ void LConv1D::mem_delta(){ if(this->verbosity_level >= 2) { std::cout << "Booked delta for: " + this->name << std::endl; } + } else { + this->delta->resize(this->output->shape[0]); } } diff --git a/src/layers/conv/layer_conv2D.cpp b/src/layers/conv/layer_conv2D.cpp index 7ebcf5d74..238d01e9f 100644 --- a/src/layers/conv/layer_conv2D.cpp +++ b/src/layers/conv/layer_conv2D.cpp @@ -83,6 +83,8 @@ void LConv::mem_delta(){ if(this->verbosity_level >= 2) { std::cout << "Booked delta for: " + this->name << std::endl; } + } else { + this->delta->resize(this->output->shape[0]); } } diff --git a/src/layers/conv/layer_conv3D.cpp b/src/layers/conv/layer_conv3D.cpp index 5cb1187fd..79794e9ba 100644 --- a/src/layers/conv/layer_conv3D.cpp +++ b/src/layers/conv/layer_conv3D.cpp @@ -89,6 +89,8 @@ void LConv3D::mem_delta(){ if(this->verbosity_level >= 2) { std::cout << "Booked delta for: " + this->name << std::endl; } + } else { + this->delta->resize(this->output->shape[0]); } } diff --git a/src/layers/pool/layer_pool1D.cpp b/src/layers/pool/layer_pool1D.cpp index 360c7324a..e66c7afe9 100644 --- a/src/layers/pool/layer_pool1D.cpp +++ b/src/layers/pool/layer_pool1D.cpp @@ -61,6 +61,8 @@ void LPool1D::mem_delta(){ if(this->verbosity_level >= 2) { std::cout << "Booked delta for: " + this->name << std::endl; } + } else { + this->delta->resize(this->output->shape[0]); } } diff --git a/src/layers/pool/layer_pool2D.cpp b/src/layers/pool/layer_pool2D.cpp index fa42ba73f..7f9ed1274 100644 --- a/src/layers/pool/layer_pool2D.cpp +++ b/src/layers/pool/layer_pool2D.cpp @@ -52,6 +52,8 @@ void LPool::mem_delta(){ if(this->verbosity_level >= 2) { std::cout << "Booked delta for: " + this->name << std::endl; } + } else { + this->delta->resize(this->output->shape[0]); } } diff --git a/src/layers/pool/layer_pool3D.cpp b/src/layers/pool/layer_pool3D.cpp index a8146fc5a..f71696c40 100644 --- a/src/layers/pool/layer_pool3D.cpp +++ b/src/layers/pool/layer_pool3D.cpp @@ -51,6 +51,8 @@ void LPool3D::mem_delta(){ if(this->verbosity_level >= 2) { std::cout << "Booked delta for: " + this->name << std::endl; } + } else { + this->delta->resize(this->output->shape[0]); } } diff --git a/src/serialization/onnx/net/import_helpers.cpp b/src/serialization/onnx/net/import_helpers.cpp index c728b6da3..342713b15 100644 --- a/src/serialization/onnx/net/import_helpers.cpp +++ b/src/serialization/onnx/net/import_helpers.cpp @@ -189,6 +189,14 @@ vector parse_IO_tensor(onnx::TypeProto::Tensor tensor, INPUT_TYPE input_typ if (input_type == INPUT_TYPE::SEQUENCE_DECODER || input_type == INPUT_TYPE::SEQUENCE_ENCODER) start_index = 2; // Avoid sequence dim + // PROVISIONAL 2022-10-10 + // Let us assume that if tensorShape.dim_size() is 1 we have to add tensorShape.dim(0) to the EDDL.Tensor shape + if (tensorShape.dim_size() == 1) { + shape.push_back(tensorShape.dim(0).dim_value()); + return shape; + } + // PROVISIONAL 2022-10-10 + for (int i = start_index; i < tensorShape.dim_size(); i++) { shape.push_back(tensorShape.dim(i).dim_value()); diff --git a/src/tensor/tensor.cpp b/src/tensor/tensor.cpp index b86b97b0a..2ef10ade8 100755 --- a/src/tensor/tensor.cpp +++ b/src/tensor/tensor.cpp @@ -524,4 +524,4 @@ bool Tensor::is_hardware_supported(string hardware){ if(hardware=="gpu") { hardware = "cuda"; } // gpu could be both "cuda" and "cudnn" bool hw_found = std::find(hw_supported.begin(), hw_supported.end(), hardware) != hw_supported.end(); return hw_found; -} \ No newline at end of file +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 71941ffd1..5bad6a714 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,6 +39,7 @@ if(MSVC) else() find_package(Threads REQUIRED) target_link_libraries(${PROJECT_TESTS_NAME} PUBLIC eddl ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") endif() diff --git a/tests/tensor/test_tensor_math_unary.cpp b/tests/tensor/test_tensor_math_unary.cpp index 91da79117..017f71d84 100644 --- a/tests/tensor/test_tensor_math_unary.cpp +++ b/tests/tensor/test_tensor_math_unary.cpp @@ -142,7 +142,7 @@ TEST(TensorTestSuite, tensor_math_unary_addT){ TEST(TensorTestSuite, tensor_math_unary_asin){ // Test #1 vector t1_shape_ref = {4}; - vector d_t1_ref = {-0.6387, std::numeric_limits::quiet_NaN(), -0.4552, std::numeric_limits::quiet_NaN()}; + vector d_t1_ref = {-0.6387, std::numeric_limits::quiet_NaN(), -0.4552, std::numeric_limits::quiet_NaN()}; Tensor* t1_ref = new Tensor(t1_shape_ref, d_t1_ref.data(), DEV_CPU); vector t1_shape = {4}; @@ -559,7 +559,7 @@ TEST(TensorTestSuite, tensor_math_unary_inv){ TEST(TensorTestSuite, tensor_math_unary_log){ // Test #1 vector t1_shape_ref = {5}; - vector d_t1_ref = { std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), -0.1128, 0.3666, -2.1286}; + vector d_t1_ref = { std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), -0.1128, 0.3666, -2.1286}; Tensor* t1_ref = new Tensor(t1_shape_ref, d_t1_ref.data(), DEV_CPU); vector t1_shape = {5}; @@ -1039,7 +1039,7 @@ TEST(TensorTestSuite, tensor_math_unary_round){ TEST(TensorTestSuite, tensor_math_unary_rsqrt){ // Test #1 vector t1_shape_ref = {4}; - vector d_t1_ref = {std::numeric_limits::quiet_NaN(), 1.8351, 0.8053, std::numeric_limits::quiet_NaN()}; + vector d_t1_ref = {std::numeric_limits::quiet_NaN(), 1.8351, 0.8053, std::numeric_limits::quiet_NaN()}; Tensor* t1_ref = new Tensor(t1_shape_ref, d_t1_ref.data(), DEV_CPU); vector t1_shape = {4}; @@ -1233,7 +1233,7 @@ TEST(TensorTestSuite, tensor_math_unary_sqr){ TEST(TensorTestSuite, tensor_math_unary_sqrt){ // Test #1 vector t1_shape_ref = {4}; - vector d_t1_ref = {std::numeric_limits::quiet_NaN(), 1.0112, 0.2883, 0.6933}; + vector d_t1_ref = {std::numeric_limits::quiet_NaN(), 1.0112, 0.2883, 0.6933}; Tensor* t1_ref = new Tensor(t1_shape_ref, d_t1_ref.data(), DEV_CPU); vector t1_shape = {4};