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
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
Cyril Moineau
aidge_core
Commits
fc39b17a
Commit
fc39b17a
authored
10 months ago
by
Houssem ROUIS
Committed by
Maxence Naud
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
avoid connecting empty shape tensor
parent
e1d961d9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/operator/Reshape.cpp
+5
-4
5 additions, 4 deletions
src/operator/Reshape.cpp
unit_tests/operator/Test_ReshapeImpl.cpp
+0
-4
0 additions, 4 deletions
unit_tests/operator/Test_ReshapeImpl.cpp
with
5 additions
and
8 deletions
src/operator/Reshape.cpp
+
5
−
4
View file @
fc39b17a
...
...
@@ -32,10 +32,8 @@ const std::string Aidge::Reshape_Op::Type = "Reshape";
bool
Aidge
::
Reshape_Op
::
forwardDims
(
bool
/*allowDataDependency*/
)
{
// check input has been associated
for
(
size_t
i
=
0
;
i
<
2
;
++
i
)
{
if
(
!
getInput
(
i
))
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"{}: input #{} should be associated with a Tensor"
,
type
(),
i
);
}
if
(
!
getInput
(
0
))
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"{}: input #0 should be associated with a Tensor"
,
type
());
}
if
(
!
getInput
(
0
)
->
empty
())
{
std
::
vector
<
DimSize_t
>
outDims
;
...
...
@@ -46,6 +44,9 @@ bool Aidge::Reshape_Op::forwardDims(bool /*allowDataDependency*/) {
// Fill shape attr if empty
if
(
this
->
template
getAttr
<
ReshapeAttr
::
Shape
>().
empty
())
{
if
(
!
getInput
(
1
))
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"{}: input #1 should be associated with a Tensor"
,
type
());
}
if
(
!
getInput
(
1
)
->
empty
())
{
this
->
template
getAttr
<
ReshapeAttr
::
Shape
>().
clear
();
// If both are provided input would override attrs
this
->
template
getAttr
<
ReshapeAttr
::
Shape
>().
reserve
(
getInput
(
1
)
->
size
());
...
...
This diff is collapsed.
Click to expand it.
unit_tests/operator/Test_ReshapeImpl.cpp
+
0
−
4
View file @
fc39b17a
...
...
@@ -58,8 +58,6 @@ TEST_CASE("[cpu/operator] Reshape(forward)") {
std
::
shared_ptr
<
Node
>
myReshape
=
Reshape
({
2
,
3
});
auto
op
=
std
::
static_pointer_cast
<
OperatorTensor
>
(
myReshape
->
getOperator
());
op
->
associateInput
(
0
,
input
);
// TODO find a way to avoid connecting an empty tensor
op
->
associateInput
(
1
,
std
::
make_shared
<
Tensor
>
(
Tensor
({})));
op
->
setDataType
(
DataType
::
Float32
);
op
->
setBackend
(
"cpu"
);
myReshape
->
forward
();
...
...
@@ -116,8 +114,6 @@ TEST_CASE("[cpu/operator] Reshape(forward)") {
std
::
shared_ptr
<
Node
>
myReshape
=
Reshape
({
3
,
2
});
auto
op
=
std
::
static_pointer_cast
<
OperatorTensor
>
(
myReshape
->
getOperator
());
op
->
associateInput
(
0
,
input
);
// TODO find a way to avoid connecting an empty tensor
op
->
associateInput
(
1
,
std
::
make_shared
<
Tensor
>
(
Tensor
({})));
op
->
setDataType
(
DataType
::
Float32
);
op
->
setBackend
(
"cpu"
);
myReshape
->
forward
();
...
...
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