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
6df070bd
Commit
6df070bd
authored
9 months ago
by
Benjamin Halimi
Committed by
Benjamin Halimi
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add attributes
parent
4086ce28
No related branches found
No related tags found
3 merge requests
!248
Draft: [Add] MulPTQ and ScalingMeta MetaOperators
,
!209
[Add] Clip Operator
,
!190
Add clipping node
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/aidge/operator/Clip.hpp
+32
-8
32 additions, 8 deletions
include/aidge/operator/Clip.hpp
python_binding/operator/pybind_Clip.cpp
+2
-2
2 additions, 2 deletions
python_binding/operator/pybind_Clip.cpp
with
34 additions
and
10 deletions
include/aidge/operator/Clip.hpp
+
32
−
8
View file @
6df070bd
...
...
@@ -19,28 +19,38 @@
#include
"aidge/graph/Node.hpp"
#include
"aidge/operator/OperatorTensor.hpp"
#include
"aidge/utils/Registrar.hpp"
#include
"aidge/utils/StaticAttributes.hpp"
#include
"aidge/utils/Types.h"
namespace
Aidge
{
enum
class
ClipAttr
{
Min
,
Max
};
class
Clip_Op
:
public
OperatorTensor
,
public
Registrable
<
Clip_Op
,
std
::
string
,
std
::
shared_ptr
<
OperatorImpl
>
(
const
Clip_Op
&
)
>
{
public:
// FIXME: change accessibility
std
::
shared_ptr
<
Tensor
>
mInput
=
std
::
make_shared
<
Tensor
>
();
const
std
::
shared_ptr
<
Tensor
>
mOutput
=
std
::
make_shared
<
Tensor
>
();
public:
static
const
std
::
string
Type
;
Clip_Op
()
:
OperatorTensor
(
Type
,
{
InputCategory
::
Data
},
1
)
{}
private:
using
Attributes_
=
StaticAttributes
<
ClipAttr
,
float
,
float
>
;
template
<
ClipAttr
e
>
using
attr
=
typename
Attributes_
::
template
attr
<
e
>;
const
std
::
shared_ptr
<
Attributes_
>
mAttributes
;
public:
Clip_Op
(
float
min
,
float
max
)
:
OperatorTensor
(
Type
,
{
InputCategory
::
Data
},
1
),
mAttributes
(
std
::
make_shared
<
Attributes_
>
(
attr
<
ClipAttr
::
Min
>
(
min
),
attr
<
ClipAttr
::
Max
>
(
max
)))
{}
/**
* @brief Copy-constructor. Copy the operator attributes and its output tensor(s), but not its input tensors (the new operator has no input associated).
* @param op Operator to copy.
*/
Clip_Op
(
const
Clip_Op
&
op
)
:
OperatorTensor
(
op
)
:
OperatorTensor
(
op
),
mAttributes
(
op
.
mAttributes
)
{
if
(
op
.
mImpl
){
SET_IMPL_MACRO
(
Clip_Op
,
*
this
,
op
.
backend
());
...
...
@@ -59,6 +69,10 @@ public:
void
setBackend
(
const
std
::
string
&
name
,
DeviceIdx_t
device
=
0
)
override
final
;
inline
std
::
shared_ptr
<
Attributes
>
attributes
()
const
override
{
return
mAttributes
;
}
inline
float
&
min
()
const
noexcept
{
return
mAttributes
->
getAttr
<
ClipAttr
::
Min
>
();
}
inline
float
&
max
()
const
noexcept
{
return
mAttributes
->
getAttr
<
ClipAttr
::
Max
>
();
}
static
const
std
::
vector
<
std
::
string
>
getInputsName
(){
return
{
"data_input"
};
}
...
...
@@ -67,9 +81,19 @@ public:
}
};
inline
std
::
shared_ptr
<
Node
>
Clip
(
const
std
::
string
&
name
=
""
)
{
return
std
::
make_shared
<
Node
>
(
std
::
make_shared
<
Clip_Op
>
(),
name
);
inline
std
::
shared_ptr
<
Node
>
Clip
(
float
min
=
0.0
f
,
float
max
=
1.0
f
,
const
std
::
string
&
name
=
""
)
{
return
std
::
make_shared
<
Node
>
(
std
::
make_shared
<
Clip_Op
>
(
min
,
max
),
name
);
}
}
namespace
{
template
<
>
const
char
*
const
EnumStrings
<
Aidge
::
ClipAttr
>::
data
[]
=
{
"Min"
,
"Max"
};
}
#endif
/* AIDGE_CORE_OPERATOR_CLIP_H_ */
This diff is collapsed.
Click to expand it.
python_binding/operator/pybind_Clip.cpp
+
2
−
2
View file @
6df070bd
...
...
@@ -20,10 +20,10 @@ namespace Aidge {
void
init_Clip
(
py
::
module
&
m
)
{
py
::
class_
<
Clip_Op
,
std
::
shared_ptr
<
Clip_Op
>
,
OperatorTensor
>
(
m
,
"ClipOp"
,
py
::
multiple_inheritance
())
.
def
(
py
::
init
<
>
(
))
.
def
(
py
::
init
<
float
,
float
>
(),
py
::
arg
(
"min"
),
py
::
arg
(
"max"
))
.
def_static
(
"get_inputs_name"
,
&
Clip_Op
::
getInputsName
)
.
def_static
(
"get_outputs_name"
,
&
Clip_Op
::
getOutputsName
);
declare_registrable
<
Clip_Op
>
(
m
,
"ClipOp"
);
m
.
def
(
"Clip"
,
&
Clip
,
py
::
arg
(
"name"
)
=
""
);
m
.
def
(
"Clip"
,
&
Clip
,
py
::
arg
(
"min"
)
=
0.0
f
,
py
::
arg
(
"max"
)
=
1.0
f
,
py
::
arg
(
"name"
)
=
""
);
}
}
// namespace Aidge
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