Skip to content
Snippets Groups Projects
Commit 1fef0e2e authored by Cyril Moineau's avatar Cyril Moineau Committed by Cyril Moineau
Browse files

Add show_cpu_version func, fix...

Add show_cpu_version func, fix #12
parent 5160226e
No related branches found
No related tags found
1 merge request!610.2.2
...@@ -2,11 +2,23 @@ cmake_minimum_required(VERSION 3.15) ...@@ -2,11 +2,23 @@ cmake_minimum_required(VERSION 3.15)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" version) file(READ "${CMAKE_SOURCE_DIR}/version.txt" version)
add_definitions(-DPROJECT_VERSION="${version}")
file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project) file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project)
message(STATUS "Project name: ${project}") message(STATUS "Project name: ${project}")
message(STATUS "Project version: ${version}") message(STATUS "Project version: ${version}")
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}")
# Define a preprocessor macro with the Git commit version
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
# Note : project name is {project} and python module name is also {project} # Note : project name is {project} and python module name is also {project}
set(module_name _${project}) # target name set(module_name _${project}) # target name
......
#ifndef AIDGE_UTILS_SYS_INFO_CPU_VERSION_INFO_H
#define AIDGE_UTILS_SYS_INFO_CPU_VERSION_INFO_H
#include "aidge/utils/Log.hpp"
namespace Aidge {
#ifndef PROJECT_VERSION // Normally defined in CMakeLists.txt
#define PROJECT_VERSION "Unknown version"
#endif
#ifndef GIT_COMMIT_HASH
#define GIT_COMMIT_HASH ""
#endif
void showCpuVersion() {
Log::info("Aidge backend CPU: {} ({}), {} {}", PROJECT_VERSION, GIT_COMMIT_HASH, __DATE__, __TIME__);
// Compiler version
#if defined(__clang__)
/* Clang/LLVM. ---------------------------------------------- */
Log::info("Clang/LLVM compiler version: {}.{}.{}\n", __clang_major__ , __clang_minor__, __clang_patchlevel__);
#elif defined(__ICC) || defined(__INTEL_COMPILER)
/* Intel ICC/ICPC. ------------------------------------------ */
Log::info("Intel ICC/ICPC compiler version: {}\n", __INTEL_COMPILER);
#elif defined(__GNUC__) || defined(__GNUG__)
/* GNU GCC/G++. --------------------------------------------- */
Log::info("GNU GCC/G++ compiler version: {}.{}.{}", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#elif defined(_MSC_VER)
/* Microsoft Visual Studio. --------------------------------- */
Log::info("Microsoft Visual Studio compiler version: {}\n", _MSC_VER);
#else
Log::info("Unknown compiler\n");
#endif
}
} // namespace Aidge
#endif // AIDGE_UTILS_SYS_INFO_CPU_VERSION_INFO_H
...@@ -6,10 +6,13 @@ namespace py = pybind11; ...@@ -6,10 +6,13 @@ namespace py = pybind11;
namespace Aidge { namespace Aidge {
void init_Aidge(py::module& /*m*/){ void init_cpu_sys_info(py::module& m);
void init_Aidge(py::module& m){
init_cpu_sys_info(m);
} }
PYBIND11_MODULE(aidge_backend_cpu, m) { PYBIND11_MODULE(aidge_backend_cpu, m) {
init_Aidge(m); init_Aidge(m);
} }
......
#include <pybind11/pybind11.h>
#include "aidge/utils/sys_info/CpuVersionInfo.hpp"
namespace py = pybind11;
namespace Aidge {
void init_cpu_sys_info(py::module& m){
m.def("show_cpu_version", &showCpuVersion);
}
}
...@@ -419,8 +419,8 @@ TEST_CASE("[cpu/scheduler] SequentialScheduler(backward)", "[scheduler][backward ...@@ -419,8 +419,8 @@ TEST_CASE("[cpu/scheduler] SequentialScheduler(backward)", "[scheduler][backward
compile_gradient(gv); compile_gradient(gv);
SequentialScheduler scheduler(gv); SequentialScheduler scheduler(gv);
scheduler.forward(); scheduler.forward();
auto predictedOutput = gv->getOrderedOutputs()[0].first; auto outNode = gv->getOrderedOutputs()[0].first;
std::shared_ptr<Tensor> predictedOutput = std::dynamic_pointer_cast<OperatorTensor>(outNode->getOperator())->getOutput(0);
std::shared_ptr<Tensor> targetOutput = std::shared_ptr<Tensor> targetOutput =
std::make_shared<Tensor>(Array4D<float, 2, 1, 5, 5>{{{{{0.0f, 1.0f, 1.0f, 2.0f, 2.0f}, std::make_shared<Tensor>(Array4D<float, 2, 1, 5, 5>{{{{{0.0f, 1.0f, 1.0f, 2.0f, 2.0f},
{2.0f, 2.0f, 3.0f, 3.0f, 3.0f}, {2.0f, 2.0f, 3.0f, 3.0f, 3.0f},
...@@ -432,7 +432,8 @@ TEST_CASE("[cpu/scheduler] SequentialScheduler(backward)", "[scheduler][backward ...@@ -432,7 +432,8 @@ TEST_CASE("[cpu/scheduler] SequentialScheduler(backward)", "[scheduler][backward
{6.0f, 6.0f, 6.0f, 6.0f, 6.0f}, {6.0f, 6.0f, 6.0f, 6.0f, 6.0f},
{6.0f, 6.0f, 6.0f, 7.0f, 7.0f}, {6.0f, 6.0f, 6.0f, 7.0f, 7.0f},
{7.0f, 7.0f, 7.0f, 7.0f, 7.0f}}}}}); {7.0f, 7.0f, 7.0f, 7.0f, 7.0f}}}}});
predictedOutput->initGrad();
REQUIRE_NOTHROW(scheduler.backward({targetOutput})); predictedOutput->setGrad(targetOutput);
REQUIRE_NOTHROW(scheduler.backward());
} }
} // namespace Aidge } // namespace Aidge
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment