InputCategory as bitwise flag and Better handle inputs
Context
Often optional input are treated as required inputs and this contribution make the InputCategory as a bitwise filter to ease filtering of needed inputs without altering the api.
Modified files
include/aidge/graph/GraphView.hpp
src/graph/GraphView.cpp
include/aidge/graph/Node.hpp
src/graph/Node.cpp
include/aidge/operator/Operator.hpp
-
include/aidge/utils/BitwiseUtils.hpp
- Added
PyBind :
python_binding/graph/pybind_GraphView.cpp
python_binding/operator/pybind_Operator.cpp
python_binding/pybind_core.cpp
Detailed major modifications
- New optional (by default old behavior) filter parameter for
std::set<std::shared_ptr<Aidge::Node>> Aidge::GraphView::inputNodes(InputCategory filter)
-
enum class InputCategory
is now an unsigned int object class allowing bitwise operations -
getNbFreeDataInputs()
now return only Data and DataOptional inputs -
addChild
now add the first available free data instead of the first data
Merge request reports
Activity
changed milestone to %aidge v0.6.0
added Bug 🐛 Enhancement ⭐ labels
assigned to @silvanosky
requested review from @pineapple
added 1 commit
- 3c955adc - edit: Operator.hpp: remove inlining as only in std17
added 1 commit
- be0c6e64 - edit: Operator.hpp: preprocessor check compiler for compatibility
added 1 commit
- 4fe09b47 - edit: Operator.hpp: preprocessor check compiler for compatibility
added 1 commit
- ed85209e - edit: Operator.hpp: preprocessor check compiler for compatibility
added 6 commits
-
a3d2762c - 1 commit from branch
eclipse/aidge:dev
- e4411e22 - edit: Node: fix optional inputs in node treated as input graph
- 37d68bf8 - WIP: filter input with bitwise category
- 5ff3ff5b - add: pybind: add filter using bitwise enum
- 6c002bb3 - edit: Operator: inline bitwise operation
- 3a6b9e69 - edit: Operator.hpp: preprocessor check compiler for compatibility
Toggle commit list-
a3d2762c - 1 commit from branch
added 8 commits
-
3a6b9e69...a6a93847 - 3 commits from branch
eclipse/aidge:dev
- b3d8d99a - edit: Node: fix optional inputs in node treated as input graph
- 745c5b80 - WIP: filter input with bitwise category
- e15c0e9a - add: pybind: add filter using bitwise enum
- 09387973 - edit: Operator: inline bitwise operation
- 9d090498 - edit: Operator.hpp: preprocessor check compiler for compatibility
Toggle commit list-
3a6b9e69...a6a93847 - 3 commits from branch
added StatusReview Ready label
added 16 commits
-
9d090498...1f6ade51 - 11 commits from branch
eclipse/aidge:dev
- 9dd67679 - edit: Node: fix optional inputs in node treated as input graph
- c85b8fe1 - WIP: filter input with bitwise category
- a59b54d4 - add: pybind: add filter using bitwise enum
- eb673079 - edit: Operator: inline bitwise operation
- fe9d4d09 - edit: Operator.hpp: preprocessor check compiler for compatibility
Toggle commit list-
9d090498...1f6ade51 - 11 commits from branch
252 252 if ((inputCategory(i) == InputCategory::Data || inputCategory(i) == InputCategory::OptionalData) changed this line in version 9 of the diff
Actually,
inputCategory(i) & InputCategory::Data
returns an enum, soto_underlying(inputCategory(i) & InputCategory::Data))
returns an unsigned int that can only be interpreted as anInputCategory
enumIt should not be use as a condition. Moreover since the new InputCategory enum class has no value 0 this condition would always be true
Edited by Maxence NaudI am not sure to understand, the underlying type doesn't need to be mapped to all possible constants, so 0 is a valid value.
I kept InputCategory as an enum class instead of original c enum which is only a syntax sugar for the underlying type where enum class is an object, so you cannot directly do bitwise operation on a class.
inputCategory(i) & InputCategory::Data
return an enum object encapsulating the result of underlying bitwise operation&
from (!370 (diffs))Then the
unsigned int
is used as a condition validation as 0 is false, and any other value is true. This allows to check if the InputCategory::Data (0b10
bit is set ininputCategory(i)
).For example:
- Optional Data have a value of
0b11
so0b11 & 0b10 = 0b10
which is true. - Optional Param have a value of
0b101
so0b101 & 0b10 = 0b00
which is false.
Edited by Charles Villard- Optional Data have a value of