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
117af588
Commit
117af588
authored
1 year ago
by
Maxence Naud
Browse files
Options
Downloads
Patches
Plain Diff
Cherry-pick Slice_Op changes from vit_operator branch
parent
47967e1f
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
include/aidge/operator/Slice.hpp
+6
-4
6 additions, 4 deletions
include/aidge/operator/Slice.hpp
src/operator/Slice.cpp
+23
-1
23 additions, 1 deletion
src/operator/Slice.cpp
with
29 additions
and
5 deletions
include/aidge/operator/Slice.hpp
+
6
−
4
View file @
117af588
...
...
@@ -29,17 +29,17 @@ enum class SliceAttr { Beginning, SliceDims };
class
Slice_Op
:
public
OperatorTensor
,
public
Registrable
<
Slice_Op
,
std
::
string
,
std
::
unique_ptr
<
OperatorImpl
>
(
const
Slice_Op
&
)
>
,
public
StaticAttributes
<
SliceAttr
,
std
::
size
_t
,
std
::
vector
<
DimSize
_t
>>
{
public
StaticAttributes
<
SliceAttr
,
std
::
vector
<
std
::
int32
_t
>
,
std
::
vector
<
std
::
int32_t
>
,
std
::
vector
<
std
::
int32
_t
>>
{
public:
static
const
std
::
string
Type
;
Slice_Op
()
=
delete
;
using
Attributes_
=
StaticAttributes
<
SliceAttr
,
std
::
size
_t
,
std
::
vector
<
DimSize
_t
>>
;
using
Attributes_
=
StaticAttributes
<
SliceAttr
,
std
::
vector
<
std
::
int32
_t
>
,
std
::
vector
<
std
::
int32_t
>
,
std
::
vector
<
std
::
int32
_t
>>
;
template
<
SliceAttr
e
>
using
attr
=
typename
Attributes_
::
template
attr
<
e
>;
Slice_Op
(
const
std
::
size_t
beginningPo
s
,
const
std
::
vector
<
DimSize_t
>
sliceDim
s
)
Slice_Op
(
const
std
::
vector
<
std
::
int32_t
>&
starts
,
const
std
::
vector
<
std
::
int32_t
>&
end
s
,
const
std
::
vector
<
std
::
int32_t
>&
axe
s
)
:
OperatorTensor
(
Type
,
1
,
0
,
1
),
Attributes_
(
attr
<
SliceAttr
::
Beginning
>
(
beginningPos
),
attr
<
SliceAttr
::
SliceDims
>
(
sliceDims
))
...
...
@@ -107,7 +107,9 @@ public:
};
inline
std
::
shared_ptr
<
Node
>
Slice
(
const
std
::
size_t
beginningPos
,
const
std
::
vector
<
DimSize_t
>
sliceDims
,
inline
std
::
shared_ptr
<
Node
>
Slice
(
const
std
::
vector
<
std
::
int32_t
>
starts
,
const
std
::
vector
<
std
::
int32_t
>
ends
,
const
std
::
vector
<
std
::
int32_t
>
axes
,
const
std
::
string
&
name
=
""
)
{
// FIXME: properly handle default w&b initialization in every cases
return
std
::
make_shared
<
Node
>
(
std
::
make_shared
<
Slice_Op
>
(
beginningPos
,
sliceDims
),
name
);
...
...
This diff is collapsed.
Click to expand it.
src/operator/Slice.cpp
+
23
−
1
View file @
117af588
...
...
@@ -12,5 +12,27 @@
#include
<string>
#include
"aidge/operator/Slice.hpp"
#include
"aidge/utils/Types.h"
#include
"aidge/utils/ErrorHandling.hpp"
const
std
::
string
Aidge
::
Slice_Op
::
Type
=
"Slice"
;
\ No newline at end of file
const
std
::
string
Aidge
::
Slice_Op
::
Type
=
"Slice"
;
void
Aidge
::
Slice_Op
::
computeOutputDims
()
{
// check input have been associated
if
(
!
getInput
(
0
)
||
(
getInput
(
0
)
->
empty
()))
{
AIDGE_THROW_OR_ABORT
(
std
::
runtime_error
,
"Every input should be associated with a Tensor"
);
}
DimSize_t
nbAxes
=
this
->
template
getAttr
<
SliceAttr
::
Axes
>().
size
();
std
::
vector
<
DimSize_t
>
outDims
=
getInput
(
0
)
->
dims
();
for
(
std
::
size_t
i
=
0
;
i
<
nbAxes
;
++
i
)
{
// For each slice operation get the params and cast them to size_t
std
::
int64_t
axis_
=
this
->
template
getAttr
<
SliceAttr
::
Axes
>()[
i
];
std
::
int64_t
start_
=
this
->
template
getAttr
<
SliceAttr
::
Starts
>()[
i
];
std
::
int64_t
end_
=
this
->
template
getAttr
<
SliceAttr
::
Ends
>()[
i
];
std
::
size_t
axis
=
axis_
>=
0
?
axis_
:
axis_
+
getInput
(
0
)
->
nbDims
();
std
::
size_t
start
=
start_
>=
0
?
start_
:
start_
+
getInput
(
0
)
->
dims
()[
axis
];
std
::
size_t
end
=
end_
>=
0
?
end_
:
end_
+
getInput
(
0
)
->
dims
()[
axis
];
}
}
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