DeepLearningOpenCpp 2.4.0
dotnet add package DeepLearningOpenCpp --version 2.4.0
NuGet\Install-Package DeepLearningOpenCpp -Version 2.4.0
<PackageReference Include="DeepLearningOpenCpp" Version="2.4.0" />
<PackageVersion Include="DeepLearningOpenCpp" Version="2.4.0" />
<PackageReference Include="DeepLearningOpenCpp" />
paket add DeepLearningOpenCpp --version 2.4.0
#r "nuget: DeepLearningOpenCpp, 2.4.0"
#:package DeepLearningOpenCpp@2.4.0
#addin nuget:?package=DeepLearningOpenCpp&version=2.4.0
#tool nuget:?package=DeepLearningOpenCpp&version=2.4.0
DeepLearningOpenCpp NuGet package
As it was pointed out by Michael Nielsen in his book Neural Networks and Deep Learning:
"In many parts of science – especially those parts that deal with simple phenomena – it’s possible to obtain very solid, very reliable evidence for quite general hypotheses. But in neural networks there are large numbers of parameters and hyper-parameters, and extremely complex interactions between them. In such extraordinarily complex systems it’s exceedingly difficult to establish reliable general statements. Understanding neural networks in their full generality is a problem that, like quantum foundations, tests the limits of the human mind."
This project, which was mostly inspired by the book by Michael Nielsen, is pursuing two main goals:
- provide an open source C++ framework for developing and experimenting with neural network-based algorithms;
- develop a high performance open source C++ library/NuGet package of machine learning algorithms.
A source-only native NuGet package that ships the headers (.h, .inl) and
sources (.cpp) of the DeepLearning
project. The package injects them into the consumer's C++ project so the
consumer's own compiler / toolset builds the library - eliminating MSVC ABI
and STL-version drift concerns inherent to prebuilt static libraries.
- Package id:
DeepLearningOpenCpp - Language standard: C++20 (
/std:c++20) - Transitive dependency:
msgpack-c-cpp-3.1.1-winsoft666([1.0.0.2, ))
Shipped files
The package contains 63 headers (.h), 14 inline files (.inl) and 26 source
files (.cpp) organised under build\native\include\ and build\native\src\.
Installation
In a native C++ project (.vcxproj):
Install-Package DeepLearningOpenCpp
or add directly to packages.config:
<package id="DeepLearningOpenCpp" version="2.2.0" targetFramework="native" />
<package id="msgpack-c-cpp-3.1.1-winsoft666" version="1.0.0.2" targetFramework="native" />
After NuGet restore, the package will:
- Add the include root
build\native\include\plus the sub-folder rootsinclude\Math\,include\NeuralNet\,include\Diagnostics\,include\ImageProcessing\andinclude\ThirdParty\toAdditionalIncludeDirectories. The sub-folder entries are required so that bare-name sibling includes inside the shipped.cppsources resolve without any extra configuration on the consumer side. - Set
<LanguageStandard>stdcpp20</LanguageStandard>on all compiled items. - Unless
DeepLearningCompileSourcesis set tofalse, add every shipped.cppto the project'sClCompileitems (with<PrecompiledHeader>NotUsing</PrecompiledHeader>).
DeepLearningCompileSources property
The single public MSBuild property exposed by the package. Override it in a
<PropertyGroup> of your .vcxproj before the Microsoft.Cpp.Default.props
import (or in a Directory.Build.props):
| Property | Default | Effect when false |
|---|---|---|
DeepLearningCompileSources |
true |
Skips injecting the shipped .cpp files (header-only consumer). |
USE_AVX2 and USE_SINGLE_PRECISION
The library sources respond to two preprocessor symbols that the consumer project is responsible for defining (the package does not inject them):
USE_AVX2- enables AVX2 SIMD intrinsics in the math kernel. You should also set<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>so the compiler emits AVX2 instructions across the whole translation unit. Omitting this symbol falls back to scalar code that runs on any x64 CPU.USE_SINGLE_PRECISION- makesDeepLearning::Realan alias forfloat(32-bit). When absent,Realisdouble(64-bit). All tensors, weight matrices and activation values follow this typedef, so the symbol must be defined consistently across every translation unit that includes DeepLearning headers, including the consumer's own.cppfiles.
Define them inside the appropriate per-configuration <ItemDefinitionGroup>:
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>USE_AVX2;USE_SINGLE_PRECISION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
Important: every project in the solution that includes DeepLearning headers must define
USE_SINGLE_PRECISION(or not) consistently with the project that compiled the sources. A mismatch causesLNK2019unresolved external errors because the template specialisations in the.libwere compiled against a differentRealtype.
Multi-project solutions (header-only consumers)
In a solution where one project (e.g. a static-lib Core) compiles the
DeepLearning sources and other projects (test DLL, wrapper DLL, executable)
consume Core transitively, only Core should compile the sources.
Otherwise the sources are compiled into every project and the linker reports
LNK2005 duplicate-symbol errors.
For each header-only consumer project:
- Install the package (so NuGet adds the include directories and language standard settings).
- Set
DeepLearningCompileSources=false:
<PropertyGroup Label="DeepLearningOpenCpp">
<DeepLearningCompileSources>false</DeepLearningCompileSources>
</PropertyGroup>
Note:
DeepLearningCompileSources=falseis only safe when the upstream.libalready exports every DeepLearning symbol the header-only consumer uses. If the consumer calls template specialisations or free functions that the.libproject never instantiates, the linker will still reportLNK2019. In that case keepDeepLearningCompileSources=true(the default) so those symbols are compiled locally.
Versioning
The package version is inferred from the most recent Git tag of the form
v<MAJOR>.<MINOR>.<PATCH> (e.g. v1.0.0 → 1.0.0). The CI workflow
publishes to nuget.org only on v* tag pushes; other pushes produce a CI
prerelease (<base>-ci.<run_number>) artifact for inspection.
Toolset
The CI runner uses windows-2022 with VCToolsVersion=14.44.35207 pinned.
This is informational only - because the package is source-only the
consumer's local toolset is what compiles the code.
Troubleshooting
LNK2019/ unresolved externals after settingDeepLearningCompileSources=false: The upstream.libdoes not export a symbol the consumer needs. Either keepDeepLearningCompileSources=true, or ensure the.libproject uses the symbol itself so the specialisation is instantiated.LNK2019withMemHandleConst<float>/MemHandleConst<double>mismatch:USE_SINGLE_PRECISIONis inconsistent between the project that compiled the.liband the consumer. Align the define across all projects.LNK2005/ "already defined" errors in a multi-project solution: The shipped.cppsources are being compiled into more than one project. Pick a single project to compile them and set<DeepLearningCompileSources>false</DeepLearningCompileSources>on the others (see Multi-project solutions above).cl : Command line error D8016 : '/arch:AVX2' and '/arch:...' incompatible: Remove the conflicting/arch:flag from your project or drop<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>from the configuration that triggers it.- PCH errors on injected
.cppfiles: ensure the consumer project does not force<PrecompiledHeader>Use</PrecompiledHeader>globally via<ItemDefinitionGroup>. The package setsNotUsingper-file, but a later<ItemDefinitionGroup>can override it. - Missing msgpack headers: confirm the
msgpack-c-cpp-3.1.1-winsoft666transitive dependency was restored; check thepackages\directory.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| native | native is compatible. |
-
native 0.0
- msgpack-c-cpp-3.1.1-winsoft666 (>= 1.0.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.