Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eclipse/aidge/aidge_core
  • hrouis/aidge_core
  • mszczep/aidge_core
  • oantoni/aidge_core
  • cguillon/aidge_core
  • jeromeh/aidge_core
  • axelfarr/aidge_core
  • cmoineau/aidge_core
  • noamzerah/aidge_core
  • lrakotoarivony/aidge_core
  • silvanosky/aidge_core
  • maab05/aidge_core
  • mick94/aidge_core
  • lucaslopez/aidge_core_ll
  • wboussella/aidge_core
  • farnez/aidge_core
  • mnewson/aidge_core
17 results
Show changes
Commits on Source (740)
Showing
with 437 additions and 224 deletions
---
Checks: "google-*, readability-identifier-naming"
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
CheckOptions:
# Case style
# Following https://webkit.org/code-style-guidelines/ :
# CamelCase for class,struct, namespace
# camelBack for variables, functions
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.AbstractClassCase'
value: 'CamelCase'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.ClassCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassConstantCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ClassConstantPrefix'
value: 's_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMemberCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ClassMemberPrefix'
value: 's_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantPointerParameterCase'
value: 'camelBack'
# camelBack for variables, functions
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMemberCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ClassMemberPrefix'
value: 's_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantPointerParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstexprFunctionCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstexprMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstexprVariableCase'
value: 'camelBack'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.EnumCase'
value: 'CamelCase'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.EnumConstantCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.FunctionCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalConstantPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalFunctionCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalVariableCase'
value: 'camelBack'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.InlineNamespaceCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalConstantPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalVariableCase'
value: 'camelBack'
- key: 'readability-identifier-naming.MacroDefinitionCase'
value: 'UPPER_CASE'
# camelBack for variables, functions
- key: 'readability-identifier-naming.MemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.MethodCase'
value: 'CamelCase'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.NamespaceCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ParameterPackCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PointerParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PrivateMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PrivateMemberPrefix'
value: 'm_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PrivateMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ProtectedMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ProtectedMemberPrefix'
value: 'm_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ProtectedMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PublicMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PublicMethodCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ScopedEnumConstantCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.StaticConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.StaticVariableCase'
value: 'camelBack'
- key: 'readability-identifier-naming.StructCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TemplateParameterCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TemplateTemplateParameterCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TypeTemplateParameterIgnoredRegexp'
value: 'expr-type'
# CamelCase for Type aliases
- key: 'readability-identifier-naming.TypeAliasCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TypedefCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TypeTemplateParameterCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.UnionCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ValueTemplateParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.VariableCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.VirtualMethodCase'
value: 'camelCase'
...
[codespell]
builtin = clear,rare,en-GB_to_en-US,names,informal,code
check-filenames =
check-hidden =
skip = */.git,*/build*,*/prefix,*/aidge_core,*/aidge_core.egg-info,*/cmake,*/future-std.clang-format
quiet-level = 2
# childs : used a lot and understandable
# dOut,inH,ro : used for testing
# deque : cpp data struct
# inout : commented code variable
# nd : commented code
# neighbours : exception to the gb to us english rule
# neighbouring : exception to the gb to us english rule
# endcode : documentation keyword
ignore-words-list = childs, dOut, inH, ro, deque, inout, stdio, nd, neighbours, neighbouring, endcode
# general
# general
.cache
# C++ Build
build*/
install*/
cppcheck-result.xml
include/aidge/core_version.h
# VSCode
.vscode
......
......@@ -4,7 +4,7 @@ $ErrorActionPreference = "Stop"
$AIDGE_DEPENDENCIES = $env:AIDGE_DEPENDENCIES -split ' '
Write-Host "Aidge dependencies : $AIDGE_DEPENDENCIES"
if ( $($AIDGE_DEPENDENCIES.Length) -eq 0) {
Write-Host "- No dependencies provided for current repsitory"
Write-Host "- No dependencies provided for current repository"
New-Item -ItemType Directory -Force -Path ".\build" | Out-Null
Remove-Item -Path ".\build\*" -Recurse -Force
} else {
......
# Version 0.5.1 (February 13, 2025)
# Version 0.5.0 (January 31, 2025)
# Version 0.4.0 (December 2024)
# Version 0.2.1 (May 14, 2024)
* rework export mechanism
* rework export mechanism
* change `Operator::computeOutputDims()` with `Operator::forwardDims()`
* automatic docstring decorators for python
* add implementation of Operators only performing data/format manipulation
......
cmake_minimum_required(VERSION 3.18)
set(CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
# Parse version.txt to retrieve Major, Minor and Path
string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" _ MATCHES ${version})
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2})
set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3})
# Retrieve latest git commit
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
project(aidge_core
VERSION ${version}
DESCRIPTION "Core algorithms for operators and graph of the AIDGE framework"
DESCRIPTION "Core algorithms for operators and graph of the AIDGE framework"
LANGUAGES CXX)
message(STATUS "Project name: ${CMAKE_PROJECT_NAME}")
message(STATUS "Project version: ${version}")
add_definitions(-DPROJECT_VERSION="${version}")
message(STATUS "Project name: ${CMAKE_PROJECT_NAME}")
message(STATUS "Project version: ${version}")
message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}")
# helper for LSP users
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Note : project name is {project} and python module name is also {project}
set(module_name _${CMAKE_PROJECT_NAME}) # target name
......@@ -36,22 +54,28 @@ endif()
##############################################
# Find system dependencies
Include(FetchContent)
set(FMT_VERSION 10.2.1)
message(STATUS "Retrieving fmt ${FMT_VERSION} from git")
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG ${FMT_VERSION} # or a later release
)
set(FMT_MIN_VERSION 10.2.1)
set(FMT_SYSTEM_HEADERS ON)
FetchContent_MakeAvailable(fmt)
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)
find_package(fmt ${FMT_MIN_VERSION} QUIET)
find_package(Threads REQUIRED)
if(NOT fmt_FOUND)
message(STATUS "fmt not found in system, retrieving from git")
Include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG master #latest
)
set(FMT_SYSTEM_HEADERS ON)
FetchContent_MakeAvailable(fmt)
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)
else()
message(STATUS "Found system fmt version ${fmt_VERSION}")
endif()
find_package(Threads REQUIRED)
##############################################
# Create target and set properties
......@@ -105,9 +129,12 @@ if (PYBIND)
include(PybindDependency)
add_pybind_dependency(${module_name})
##
target_link_libraries(${pybind_module_name} PUBLIC fmt::fmt)
endif()
target_link_libraries(${module_name} PUBLIC Threads::Threads fmt::fmt)
target_link_libraries(${module_name} PUBLIC fmt::fmt)
target_link_libraries(${module_name} PUBLIC Threads::Threads)
target_compile_features(${module_name} PRIVATE cxx_std_14)
if (DOSANITIZE STREQUAL "ON")
......@@ -152,9 +179,16 @@ endif()
# Installation instructions
if(NOT $ENV{AIDGE_INSTALL} STREQUAL "")
set(CMAKE_INSTALL_PREFIX $ENV{AIDGE_INSTALL})
message(WARNING "CMAKE_INSTALL_PREFIX set to env variable AIDGE_INSTALL by default = ${CMAKE_INSTALL_PREFIX}")
message(WARNING "CMAKE_INSTALL_PREFIX set to env variable AIDGE_INSTALL by default (${CMAKE_INSTALL_PREFIX})")
endif()
message(STATUS "Creating ${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/core_version.h")
# Generate version.h file from config file version.h.in
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/version.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/core_version.h"
)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
......
include README.md LICENCE
recursive-include aidge_core *.py
include README.md LICENSE
recursive-include aidge_core *.py
recursive-exclude aidge_core/unit_tests *.py
recursive-include aidge_core/aidge_export_aidge *
recursive-include aidge_core/export_utils/templates *
recursive-include include *.hpp
recursive-include src *.cpp
recursive-include python_binding *.cpp
......
......@@ -8,7 +8,7 @@ You can find here the C++ code of the Core library of Aidge.
## Pip installation
To install aidge_core using pip, run the following command in your python environnement :
To install aidge_core using pip, run the following command in your python environment :
``` bash
pip install . -v
```
......@@ -23,7 +23,7 @@ pip install . -v
To setup aidge_core using pip in development (or editable mode), use the `--no-build-isolation -e` options to pip.
For instance run the following command in your python environnement for a typical setup :
For instance run the following command in your python environment for a typical setup :
``` bash
export AIDGE_BUILD_TEST=ON # enable C++ unit tests
export AIDGE_PYTHON_BUILD_TYPE= # default flags (no debug info but fastest build time)
......@@ -85,7 +85,7 @@ make all install
| Option | Value type | Description |
|:----------:|:----------:|:-----------:|
| *-DCMAKE_INSTALL_PREFIX:PATH* | ``str`` | Path to the install folder |
| *-DCMAKE_BUILD_TYPE* | ``str`` | If ``Debug``, compile in debug mode, ``Release`` compile with highest optimisations or "" (empty) , default= ``Release`` |
| *-DCMAKE_BUILD_TYPE* | ``str`` | If ``Debug``, compile in debug mode, ``Release`` compile with highest optimizations or "" (empty) , default= ``Release`` |
| *-DWERROR* | ``bool`` | If ``ON`` show warning as error during compilation phase, default=``OFF`` |
| *-DTEST* | ``bool`` | If ``ON`` build C++ unit tests, default=``ON`` |
| *-DPYBIND* | ``bool`` | If ``ON`` activate python binding, default=``OFF`` |
......
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(fmt)
find_dependency(fmt @FMT_MIN_VERSION@)
find_dependency(Threads)
set(AIDGE_REQUIRES_PYTHON @AIDGE_REQUIRES_PYTHON@)
set(AIDGE_PYTHON_HAS_EMBED @AIDGE_PYTHON_HAS_EMBED@)
......
......@@ -7,8 +7,9 @@ http://www.eclipse.org/legal/epl-2.0.
SPDX-License-Identifier: EPL-2.0
"""
from .aidge_core import * # import so generated by PyBind
from .export_utils import ExportNode, generate_file, generate_str
from .aidge_export_aidge import *
from . import utils
from ._version import *
from aidge_core.aidge_core import * # import so generated by PyBind
import aidge_core.export_utils
import aidge_core.utils
from aidge_core.aidge_export_aidge import serialize_to_cpp
from aidge_core.show_graphview import gview_to_json
from aidge_core.mem_info import *
......@@ -5,4 +5,4 @@ FILE = Path(__file__).resolve()
ROOT_EXPORT = FILE.parents[0]
from .operator_export import *
from .export import export
from .export import serialize_to_cpp
......@@ -2,15 +2,14 @@ import aidge_core
import shutil
import os
from pathlib import Path
from .utils import supported_operators, OPERATORS_REGISTRY
from . import ROOT_EXPORT
from aidge_core import ExportNode, generate_file
import aidge_core.export_utils
from . import ROOT_EXPORT
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.export_utils import generate_file
def export(export_folder: str,
def serialize_to_cpp(export_folder: str,
graph_view: aidge_core.GraphView,
enable_python_binding: bool = True,
):
......@@ -59,7 +58,6 @@ def export(export_folder: str,
open_nodes = list(graph_view.get_input_nodes())
# List of Aidge nodes already explored
closed_nodes = []
while open_nodes:
node = open_nodes.pop(0)
if node in closed_nodes:
......@@ -80,24 +78,34 @@ def export(export_folder: str,
continue
# Next nodes to treat are children of current node
open_nodes += list(node.get_children())
if node.type() in supported_operators():
list_operators.append(node.type())
op = OPERATORS_REGISTRY[node.type()](node)
# TODO: list_configs and list_actions don't need to be passed by argument
# Export the configuration
list_configs = op.export(export_folder_path, list_configs)
# Add forward kernel
list_actions = op.forward(list_actions)
else:
raise RuntimeError(f"Operator: {node.type()} is not supported")
node.get_operator().set_backend(ExportSerialize._name)
op_impl = node.get_operator().get_impl()
if op_impl is None:
raise RuntimeError(f"Operator {node.name()}[{node.type()}] doesn't have an implementation.")
if not isinstance(op_impl, ExportSerialize):
raise RuntimeError(f"Operator {node.name()}[{node.type()}] doesn't have an exportable backend ({op_impl}).")
required_specs = op_impl.get_required_spec()
specs = op_impl.get_best_match(required_specs)
export_node = op_impl.get_export_node(specs)
if export_node is None:
raise RuntimeError(f"Could not find export node for {node.name()}[{node.type()}].")
op = export_node(
node, None)
# set_operator.add(node.type())
# TODO: list_configs and list_actions don't need to be passed by argument
# Export the configuration
list_configs += op.export(export_folder_path)
# Add forward kernel
list_actions += op.forward()
closed_nodes.append(node)
list_operators = list(dict.fromkeys(list_operators)) # make unique
# Generate full dnn.cpp
aidge_core.generate_file(
aidge_core.export_utils.generate_file(
export_folder_path / "src/dnn.cpp",
ROOT_EXPORT / "templates/dnn.jinja",
headers=list_configs,
......
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@ExportSerialize.register("Add", ImplSpec(IOSpec(dtype.any)))
class Add(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.config_template = ""
self.forward_template = str(
ROOT_EXPORT / "templates/graph_ctor/add.jinja")
self.include_list = ["aidge/operator/Add.hpp"]
self.kernels_to_copy = []
from aidge_core.aidge_export_aidge.utils import operator_register, parse_node_input
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core import ExportNode, generate_file, generate_str
from pathlib import Path
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@operator_register("Conv")
class Conv(ExportNode):
def __init__(self, node):
super().__init__(node)
def export(self, export_folder:Path, list_configs:list):
include_path = f"attributes/{self.name}.hpp"
filepath = export_folder / f"include/{include_path}"
generate_file(
filepath,
ROOT_EXPORT / "templates/attributes/conv.jinja",
name=self.name,
**self.attributes
)
list_configs.append(include_path)
return list_configs
def forward(self, list_actions:list):
list_actions.append(generate_str(
ROOT_EXPORT /"templates/graph_ctor/conv.jinja",
name=self.name,
inputs=parse_node_input(self.node.inputs()),
**self.attributes
))
return list_actions
@ExportSerialize.register(["Conv1D", "Conv2D"], ImplSpec(IOSpec(dtype.any)))
class Conv(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.config_template = str(
ROOT_EXPORT / "templates/attributes/conv.jinja")
self.forward_template = str(
ROOT_EXPORT /"templates/graph_ctor/conv.jinja")
self.include_list = ["aidge/operator/Conv.hpp"]
self.kernels_to_copy = []
self.config_path = "include/attributes"
self.config_extension = "hpp"
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@ExportSerialize.register(["ConvDepthWise1D", "ConvDepthWise2D"], ImplSpec(IOSpec(dtype.any)))
class ConvDepthWise(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.config_template = str(
ROOT_EXPORT / "templates/attributes/conv_depth_wise.jinja")
self.forward_template = str(
ROOT_EXPORT /"templates/graph_ctor/conv_depth_wise.jinja")
self.include_list = ["aidge/operator/ConvDepthWise.hpp"]
self.kernels_to_copy = []
self.config_path = "include/attributes"
self.config_extension = "hpp"
from aidge_core.aidge_export_aidge.utils import operator_register,parse_node_input
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core import ExportNode, generate_file, generate_str
from pathlib import Path
@operator_register("FC")
class FC(ExportNode):
def __init__(self, node):
super().__init__(node)
def export(self, export_folder:Path, list_configs:list):
include_path = f"attributes/{self.name}.hpp"
filepath = export_folder / f"include/{include_path}"
generate_file(
filepath,
ROOT_EXPORT / "templates/attributes/fc.jinja",
name=self.name,
InChannels=self.inputs_dims[1][1],
OutChannels=self.operator.out_channels(),
**self.attributes
)
list_configs.append(include_path)
return list_configs
def forward(self, list_actions:list):
list_actions.append(generate_str(
ROOT_EXPORT / "templates/graph_ctor/fc.jinja",
name=self.name,
inputs=parse_node_input(self.node.inputs()),
**self.attributes
))
return list_actions
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@ExportSerialize.register("FC", ImplSpec(IOSpec(dtype.any)))
class FC(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.config_template = str(
ROOT_EXPORT / "templates/attributes/fc.jinja")
self.forward_template = str(
ROOT_EXPORT / "templates/graph_ctor/fc.jinja")
self.include_list = ["aidge/operator/FC.hpp"]
self.kernels_to_copy = []
self.config_path = "include/attributes"
self.config_extension = "hpp"
from aidge_core.aidge_export_aidge.utils import operator_register, parse_node_input
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core import ExportNode, generate_file, generate_str
from pathlib import Path
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@operator_register("MaxPooling")
class MaxPooling(ExportNode):
def __init__(self, node):
super().__init__(node)
def export(self, export_folder:Path, list_configs:list):
include_path = f"attributes/{self.name}.hpp"
filepath = export_folder / f"include/{include_path}"
generate_file(
filepath,
ROOT_EXPORT / "templates/attributes/maxpooling.jinja",
name=self.name,
**self.attributes
)
list_configs.append(include_path)
return list_configs
def forward(self, list_actions:list):
list_actions.append(generate_str(
ROOT_EXPORT / "templates/graph_ctor/maxpooling.jinja",
name=self.name,
inputs=parse_node_input(self.node.inputs()),
**self.attributes
))
return list_actions
@ExportSerialize.register(["MaxPooling1D", "MaxPooling2D", "MaxPooling3D"], ImplSpec(IOSpec(dtype.any)))
class MaxPooling(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.config_template = str(
ROOT_EXPORT / "templates/attributes/maxpooling.jinja")
self.forward_template = str(
ROOT_EXPORT / "templates/graph_ctor/maxpooling.jinja")
self.include_list = ["aidge/operator/MaxPooling.hpp"]
self.kernels_to_copy = []
self.config_path = "include/attributes"
self.config_extension = "hpp"
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@ExportSerialize.register(["Pad1D", "Pad2D"], ImplSpec(IOSpec(dtype.any)))
class Pad(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.config_template = str(
ROOT_EXPORT / "templates/attributes/pad.jinja")
self.forward_template = str(
ROOT_EXPORT /"templates/graph_ctor/pad.jinja")
self.include_list = ["aidge/operator/Pad.hpp"]
self.kernels_to_copy = []
self.config_path = "include/attributes"
self.config_extension = "hpp"
from aidge_core.aidge_export_aidge.utils import operator_register
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core import dtype, ExportNode, generate_file, generate_str
import numpy as np
from pathlib import Path
# Convert aidge datatype to C++ type
datatype_converter = {
dtype.float64 : "double",
dtype.float32 : "float",
dtype.float16 : "half_float::half",
dtype.int8 : "int8_t",
dtype.int16 : "int16_t",
dtype.int32 : "int32_t",
dtype.int64 : "int64_t",
dtype.uint8 : "uint8_t",
dtype.uint16 : "uint16_t",
dtype.uint32 : "uint32_t",
dtype.uint64 : "uint64_t"
}
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@operator_register("Producer")
class Producer(ExportNode):
@ExportSerialize.register("Producer", ImplSpec(IOSpec(dtype.any)))
class Producer(ExportNodeCpp):
"""
If there is a standardization of the export operators
then this class should be just a inheritance of ProducerCPP
"""
def __init__(self, node):
super().__init__(node)
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
child, in_idx = self.node.output(0)[0]
self.tensor_name = f"{child.name()}_{in_idx}"
self.values = np.array(self.operator.get_output(0))
def export(self, export_folder:Path, list_configs:list):
assert(len(self.node.output(0)) == 1)
include_path = f"parameters/{self.tensor_name}.hpp"
filepath = export_folder / f"include/{include_path}"
self.values = np.array(self.operator.get_output(0))
aidge_tensor = self.operator.get_output(0)
aidge_type = aidge_tensor.dtype()
if aidge_type in datatype_converter:
datatype = datatype_converter[aidge_type]
else:
raise RuntimeError(f"No conversion found for data type {aidge_type}.")
generate_file(
filepath,
ROOT_EXPORT / "templates/parameter.jinja",
dims = aidge_tensor.dims(),
data_t = datatype, # TODO : get data from producer
name = self.tensor_name,
values = str(aidge_tensor)
)
list_configs.append(include_path)
return list_configs
self.config_template = str(
ROOT_EXPORT / "templates/parameter.jinja")
self.forward_template = str(
ROOT_EXPORT / "templates/graph_ctor/producer.jinja")
self.attributes["tensor_name"] = f"{child.name()}_{in_idx}"
self.attributes["values"] = str(self.operator.get_output(0))
self.include_list = ["aidge/operator/Producer.hpp"]
self.kernels_to_copy = []
self.config_path = "include/attributes"
self.config_extension = "hpp"
def forward(self, list_actions:list):
list_actions.append(generate_str(
ROOT_EXPORT / "templates/graph_ctor/producer.jinja",
name=self.name,
tensor_name=self.tensor_name,
**self.attributes
))
return list_actions
from aidge_core.aidge_export_aidge.utils import operator_register, parse_node_input
from aidge_core import ExportNode, generate_str
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.aidge_export_aidge import ROOT_EXPORT
from pathlib import Path
from aidge_core.export_utils import ExportNodeCpp
from aidge_core import ImplSpec, IOSpec, dtype
@operator_register("ReLU")
class ReLU(ExportNode):
def __init__(self, node):
super().__init__(node)
def export(self, export_folder:Path, list_configs:list):
return list_configs
def forward(self, list_actions:list):
list_actions.append(generate_str(
ROOT_EXPORT / "templates/graph_ctor/relu.jinja",
name=self.name,
inputs=parse_node_input(self.node.inputs()),
**self.attributes
))
return list_actions
@ExportSerialize.register("ReLU", ImplSpec(IOSpec(dtype.any)))
class ReLU(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.config_template = ""
self.forward_template = str(
ROOT_EXPORT / "templates/graph_ctor/relu.jinja")
self.include_list = ["aidge/operator/ReLU.hpp"]
self.kernels_to_copy = []