Skip to content
Snippets Groups Projects

[Add] broadcasting for Arithmetic Operators

Merged Houssem ROUIS requested to merge hrouis/aidge_core:broadcasting into dev
1 unresolved thread

This merge request is dedicated to enabling broadcasting on binary operators (Add, Mul, Div, Sub, Pow). The expected behaviour is the same as numpy

Here are examples of supported broadcasting

Tensor_A shape 3 2 1 3
Tensor_B shape 1 2 4 3
Output shape 3 2 4 3
Tensor_A shape 3 2 1 3
Tensor_C shape 3
Output shape 3 2 1 3
Edited by Maxence Naud

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
23
24 void Aidge::ArithmeticOperator::computeOutputDims() {
25 // check inputs have been associated
26 if (!getInput(0) || !getInput(1)) {
27 AIDGE_THROW_OR_ABORT(std::runtime_error, "At least one input was not connected");
28 }
29
30 // if (getInput(0)->empty() || getInput(1)->empty()) {
31 // AIDGE_THROW_OR_ABORT(std::runtime_error, "At least one input is empty");
32 // }
33
34 std::vector<std::vector<std::size_t>> inputsDims;
35 for (std::size_t i = 0; i < nbInputs(); i++)
36 {
37 inputsDims.push_back(getInput(i)->dims());
38 }
    • Resolved by Houssem ROUIS

      @hrouis,

      I am not sure it is a good idea to add the ArithmeticOperator sub class.

      This class only update the behavior of computeOutputDims, I would be more in favor of copy pasting this function in the different operators.

      I think we should avoid to add to much layer of inheritance in the code as it can hurt code readability and in this case the code duplication is not substancial.

      @olivierbichler @pineapple

  • Houssem ROUIS added 3 commits

    added 3 commits

    Compare with previous version

  • This MR is related to #64 (closed)

  • Houssem ROUIS added 1 commit

    added 1 commit

    • c67e943c - remove ArithmeticOperator class

    Compare with previous version

  • Maxence Naud added 37 commits

    added 37 commits

    • c67e943c...95077929 - 34 commits from branch eclipse/aidge:dev
    • 5cf910bf - Merge branch 'dev' into broadcasting
    • 1b16db67 - [Add] Scalar constructor for Tensor and int8 support
    • d6e0e879 - [Add][WIP] Test for 'Div::computeOutputDims()' memeber function

    Compare with previous version

  • Maxence Naud added 83 commits

    added 83 commits

    Compare with previous version

  • Maxence Naud added 2 commits

    added 2 commits

    • 698d0028 - Standardize and optimize TensorImpl, Tensor and arithmetic operators
    • 124c6d39 - [Add] Tests for arithmetic operators' computeOutputDims() member function

    Compare with previous version

  • Maxence Naud added Unit-test label and removed Feature 🚀 label

    added Unit-test label and removed Feature 🚀 label

  • added Missing label

  • assigned to @pineapple

  • Maxence Naud added 1 commit

    added 1 commit

    • 97740d0d - [Fix] std::accumulate include in TensorImpl

    Compare with previous version

  • Tests with scalar values are commented because scalar Tensors are not supported yet by the computeOutputDims() member function of Operators.

    It should be solved in the merge request that integrates scalar Tensors. Here, a first scalar Tensor constructor is added.

  • Maxence Naud approved this merge request

    approved this merge request

  • Maxence Naud mentioned in commit 0b990efd

    mentioned in commit 0b990efd

  • merged

  • mentioned in issue #64 (closed)

  • Maxence Naud mentioned in merge request !105 (merged)

    mentioned in merge request !105 (merged)

  • Please register or sign in to reply
    Loading