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
80f23f80
Commit
80f23f80
authored
1 year ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
Removed mSizeM1 which is not that usefull
parent
711c2c48
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/aidge/data/Tensor.hpp
+8
-30
8 additions, 30 deletions
include/aidge/data/Tensor.hpp
with
8 additions
and
30 deletions
include/aidge/data/Tensor.hpp
+
8
−
30
View file @
80f23f80
...
...
@@ -40,8 +40,7 @@ class Tensor : public Data,
std
::
shared_ptr
<
Tensor
>
mGrad
;
/** Pointer to the associated gradient Tensor instance. */
// Cached data
std
::
size_t
mSize
;
/** Number of elements in the Tensor. */
std
::
size_t
mSizeM1
;
/** Number of elements in the N-1 first dimensions */
std
::
size_t
mSize
=
0
;
/** Number of elements in the Tensor. */
public:
static
constexpr
const
char
*
Type
=
"Tensor"
;
...
...
@@ -52,10 +51,7 @@ class Tensor : public Data,
*/
Tensor
(
DataType
dataType
=
DataType
::
Float32
)
:
Data
(
Type
),
mDataType
(
dataType
),
mDims
({}),
mSize
(
0
),
mSizeM1
(
0
)
mDataType
(
dataType
)
{
// ctor
}
...
...
@@ -68,8 +64,7 @@ class Tensor : public Data,
:
Data
(
Type
),
mDataType
(
otherTensor
.
mDataType
),
mDims
(
otherTensor
.
mDims
),
mSize
(
otherTensor
.
mSize
),
mSizeM1
(
otherTensor
.
mSizeM1
)
mSize
(
otherTensor
.
mSize
)
{
if
(
otherTensor
.
hasImpl
())
{
mImpl
=
Registrar
<
Tensor
>::
create
({
otherTensor
.
mImpl
->
backend
(),
dataType
()})(
*
this
);
...
...
@@ -90,8 +85,7 @@ class Tensor : public Data,
mDataType
(
NativeType
<
T
>::
type
),
mDims
({
SIZE_0
}),
mImpl
(
Registrar
<
Tensor
>::
create
({
"cpu"
,
NativeType
<
T
>::
type
})(
*
this
)),
mSize
(
SIZE_0
),
mSizeM1
(
SIZE_0
)
{
mSize
(
SIZE_0
)
{
mImpl
->
copyFromHost
(
&
arr
.
data
[
0
],
SIZE_0
);
}
...
...
@@ -117,8 +111,7 @@ class Tensor : public Data,
mDataType
(
NativeType
<
T
>::
type
),
mDims
({
SIZE_0
,
SIZE_1
}),
mImpl
(
Registrar
<
Tensor
>::
create
({
"cpu"
,
NativeType
<
T
>::
type
})(
*
this
)),
mSize
(
SIZE_0
*
SIZE_1
),
mSizeM1
(
SIZE_1
)
{
mSize
(
SIZE_0
*
SIZE_1
)
{
mImpl
->
copyFromHost
(
&
arr
.
data
[
0
][
0
],
SIZE_0
*
SIZE_1
);
}
...
...
@@ -145,8 +138,7 @@ class Tensor : public Data,
mDataType
(
NativeType
<
T
>::
type
),
mDims
({
SIZE_0
,
SIZE_1
,
SIZE_2
}),
mImpl
(
Registrar
<
Tensor
>::
create
({
"cpu"
,
NativeType
<
T
>::
type
})(
*
this
)),
mSize
(
SIZE_0
*
SIZE_1
*
SIZE_2
),
mSizeM1
(
SIZE_1
*
SIZE_2
)
{
mSize
(
SIZE_0
*
SIZE_1
*
SIZE_2
)
{
mImpl
->
copyFromHost
(
&
arr
.
data
[
0
][
0
][
0
],
SIZE_0
*
SIZE_1
*
SIZE_2
);
}
...
...
@@ -174,8 +166,7 @@ class Tensor : public Data,
mDataType
(
NativeType
<
T
>::
type
),
mDims
({
SIZE_0
,
SIZE_1
,
SIZE_2
,
SIZE_3
}),
mImpl
(
Registrar
<
Tensor
>::
create
({
"cpu"
,
NativeType
<
T
>::
type
})(
*
this
)),
mSize
(
SIZE_0
*
SIZE_1
*
SIZE_2
*
SIZE_3
),
mSizeM1
(
SIZE_1
*
SIZE_2
*
SIZE_3
)
{
mSize
(
SIZE_0
*
SIZE_1
*
SIZE_2
*
SIZE_3
)
{
mImpl
->
copyFromHost
(
&
arr
.
data
[
0
][
0
][
0
][
0
],
SIZE_0
*
SIZE_1
*
SIZE_2
*
SIZE_3
);
}
...
...
@@ -334,12 +325,6 @@ class Tensor : public Data,
*/
constexpr
std
::
size_t
size
()
const
{
return
mSize
;
}
/**
* @brief Get the number of elements in the N-1 dimensions of the Tensor object.
* @return constexpr std::size_t
*/
constexpr
std
::
size_t
sizeM1
()
const
{
return
mSizeM1
;
}
/**
* @brief Change the dimensions of the Tensor object according to the given argument.
* If the overall size is not changed (meaning we actually only performed a
...
...
@@ -673,17 +658,10 @@ private:
///\bug not protected against overflow
std
::
size_t
computeSize
()
{
if
(
mDims
.
empty
())
{
mSizeM1
=
DimSize_t
(
0
);
mSize
=
DimSize_t
(
0
);
}
else
if
(
mDims
.
size
()
==
1
)
{
mSizeM1
=
mDims
[
0
];
mSize
=
mDims
[
0
];
}
else
{
mSizeM1
=
std
::
accumulate
(
++
mDims
.
begin
(),
mDims
.
end
(),
DimSize_t
(
1
),
std
::
multiplies
<
DimSize_t
>
());
mSize
=
static_cast
<
std
::
size_t
>
(
mSizeM1
*
mDims
[
0
]);
mSize
=
std
::
accumulate
(
mDims
.
begin
(),
mDims
.
end
(),
DimSize_t
(
1
),
std
::
multiplies
<
DimSize_t
>
());
}
return
mSize
;
...
...
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