Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
aidge_core
Commits
6424edc9
Commit
6424edc9
authored
1 year ago
by
Maxence Naud
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into dev
parents
1bd36647
b9d7bf31
No related branches found
No related tags found
1 merge request
!105
version 0.2.0
Pipeline
#38205
passed
1 year ago
Stage: static_analysis
Stage: build
Stage: test
Stage: coverage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/operator/Reshape.cpp
+23
-13
23 additions, 13 deletions
src/operator/Reshape.cpp
with
23 additions
and
13 deletions
src/operator/Reshape.cpp
+
23
−
13
View file @
6424edc9
...
...
@@ -9,38 +9,48 @@
*
********************************************************************************/
#include
<cstddef>
#include
<cstddef>
// std::size_t
#include
<cstdint>
// std::int64_t
#include
<stdexcept>
// std::runtime_error
#include
<string>
#include
<vector>
#include
"aidge/operator/Reshape.hpp"
#include
"aidge/utils/Types.h"
#include
"aidge/utils/ErrorHandling.hpp"
#include
"aidge/utils/Types.h"
const
std
::
string
Aidge
::
Reshape_Op
::
Type
=
"Reshape"
;
void
Aidge
::
Reshape_Op
::
computeOutputDims
()
{
// check input
s
ha
ve
been associated
// check input ha
s
been associated
if
(
!
getInput
(
0
))
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"Input was not connected"
);
}
DimSize_t
nbOutDims
=
this
->
template
getAttr
<
ReshapeAttr
::
Shape
>().
size
();
std
::
vector
<
DimSize_t
>
outDims
;
// variables to handle a negative dimension
bool
foundNegativeDimension
=
false
;
std
::
size_t
outSize
=
1
;
for
(
std
::
size_t
i
=
0
;
i
<
nbOutDims
;
++
i
)
DimIdx_t
negativeIndex
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
this
->
template
getAttr
<
ReshapeAttr
::
Shape
>().
size
();
++
i
)
{
int
dimSize
=
this
->
template
getAttr
<
ReshapeAttr
::
Shape
>()[
i
];
if
(
dimSize
<
1
)
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"bad dimension value"
);
std
::
int64_t
dimSize
=
this
->
template
getAttr
<
ReshapeAttr
::
Shape
>()[
i
];
if
(
dimSize
<
0
)
{
if
(
foundNegativeDimension
)
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"Found more than one negative dimension in Reshape Operator."
);
}
foundNegativeDimension
=
true
;
dimSize
=
1
;
negativeIndex
=
static_cast
<
DimIdx_t
>
(
i
);
}
outDims
.
push_back
(
dimSize
);
outSize
*=
dimSize
;
outDims
.
push_back
(
static_cast
<
DimSize_t
>
(
dimSize
)
)
;
outSize
*=
static_cast
<
DimSize_t
>
(
dimSize
)
;
}
if
(
getInput
(
0
)
->
size
()
!=
outSize
)
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"Output shape must give the same size as input"
)
;
if
(
foundNegativeDimension
)
{
outDims
[
negativeIndex
]
=
(
getInput
(
0
)
->
size
())
/
outSize
;
}
mOutputs
[
0
]
->
resize
(
outDims
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment