Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_backend_cpu
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_backend_cpu
Commits
31f049fc
Commit
31f049fc
authored
1 year ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
Use new conversion facilities from code for Conv
parent
4ae84dbb
No related branches found
No related tags found
2 merge requests
!29
Temporary master branch
,
!26
Draft: Add Convert operator (a.k.a. Transmitter)
Pipeline
#35472
failed
1 year ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/operator/ConvImpl.cpp
+28
-7
28 additions, 7 deletions
src/operator/ConvImpl.cpp
with
28 additions
and
7 deletions
src/operator/ConvImpl.cpp
+
28
−
7
View file @
31f049fc
...
@@ -33,14 +33,35 @@ void Aidge::ConvImpl2D_cpu::forward() {
...
@@ -33,14 +33,35 @@ void Aidge::ConvImpl2D_cpu::forward() {
assert
(
mOp
.
getRawInput
(
2
)
&&
"missing input #2"
);
assert
(
mOp
.
getRawInput
(
2
)
&&
"missing input #2"
);
// Find the correct kernel type
// Find the correct kernel type
auto
kernelFunc
=
const
auto
outputDataType
=
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawOutput
(
0
))
->
dataType
();
Registrar
<
ConvImpl2DForward_cpu
>::
create
({
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
0
))
->
dataType
(),
const
Registrar
<
ConvImpl2DForward_cpu
>::
registrar_key
registrarKey
=
{
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
1
))
->
dataType
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
0
))
->
dataType
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
2
))
->
dataType
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
1
))
->
dataType
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawOutput
(
0
))
->
dataType
()});
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
2
))
->
dataType
(),
outputDataType
};
Registrar
<
ConvImpl2DForward_cpu
>::
registrar_type
kernelFunc
;
if
(
Registrar
<
ConvImpl2DForward_cpu
>::
exists
(
registrarKey
))
{
// One exists with the right inputs/output types
kernelFunc
=
Registrar
<
ConvImpl2DForward_cpu
>::
create
(
registrarKey
);
}
else
{
// Otherwise, fallback to the kernel with all types matching output type
kernelFunc
=
Registrar
<
ConvImpl2DForward_cpu
>::
create
({
outputDataType
,
outputDataType
,
outputDataType
,
outputDataType
});
}
// Convert input data (no overhead if not needed!)
// TODO: right now, if needed, memory will be allocated/deallocated at each
// call to forward(). We might put the following shared_ptr as members of
// this class to avoid that.
std
::
shared_ptr
<
Tensor
>
input0Fallback
,
input1Fallback
,
input2Fallback
;
const
auto
&
input0
=
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
0
))
->
refCast
(
input0Fallback
,
*
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawOutput
(
0
)));
const
auto
&
input1
=
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
1
))
->
refCast
(
input1Fallback
,
*
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawOutput
(
0
)));
const
auto
&
input2
=
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
2
))
->
refCast
(
input2Fallback
,
*
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawOutput
(
0
)));
// Call kernel
// Call kernel
kernelFunc
(
dynamic_cast
<
const
Conv_Op
<
2
>&>
(
mOp
).
getStaticAttributes
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
0
))
->
template
dims
<
4
>(),
kernelFunc
(
dynamic_cast
<
const
Conv_Op
<
2
>&>
(
mOp
).
getStaticAttributes
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
0
))
->
template
dims
<
4
>(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
0
))
->
getImpl
()
->
rawPtr
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
1
))
->
getImpl
()
->
rawPtr
(),
input0
.
getImpl
()
->
rawPtr
(),
input1
.
getImpl
()
->
rawPtr
(),
input2
.
getImpl
()
->
rawPtr
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawInput
(
2
))
->
getImpl
()
->
rawPtr
(),
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawOutput
(
0
))
->
getImpl
()
->
rawPtr
());
std
::
static_pointer_cast
<
Tensor
>
(
mOp
.
getRawOutput
(
0
))
->
getImpl
()
->
rawPtr
());
}
}
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