Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
6008ad21
Commit
6008ad21
authored
Jun 11, 2016
by
Davis King
Browse files
Made the resizable_tensor's assignment operator work in a more sensible way.
parent
7272bc74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
57 deletions
+9
-57
dlib/dnn/tensor.h
dlib/dnn/tensor.h
+2
-21
dlib/dnn/tensor_abstract.h
dlib/dnn/tensor_abstract.h
+7
-36
No files found.
dlib/dnn/tensor.h
View file @
6008ad21
...
@@ -332,31 +332,12 @@ namespace dlib
...
@@ -332,31 +332,12 @@ namespace dlib
const
matrix_exp
<
EXP
>&
item
const
matrix_exp
<
EXP
>&
item
)
)
{
{
set_size
(
item
.
nr
(),
item
.
nc
());
if
(
!
(
num_samples
()
==
item
.
nr
()
&&
k
()
*
nr
()
*
nc
()
==
item
.
nc
()))
set_size
(
item
.
nr
(),
item
.
nc
());
tensor
::
operator
=
(
item
);
tensor
::
operator
=
(
item
);
return
*
this
;
return
*
this
;
}
}
template
<
typename
EXP
>
resizable_tensor
&
operator
+=
(
const
matrix_exp
<
EXP
>&
item
)
{
set_size
(
item
.
nr
(),
item
.
nc
());
tensor
::
operator
+=
(
item
);
return
*
this
;
}
template
<
typename
EXP
>
resizable_tensor
&
operator
-=
(
const
matrix_exp
<
EXP
>&
item
)
{
set_size
(
item
.
nr
(),
item
.
nc
());
tensor
::
operator
-=
(
item
);
return
*
this
;
}
void
set_size
(
void
set_size
(
long
n_
,
long
k_
=
1
,
long
nr_
=
1
,
long
nc_
=
1
long
n_
,
long
k_
=
1
,
long
nr_
=
1
,
long
nc_
=
1
)
)
...
...
dlib/dnn/tensor_abstract.h
View file @
6008ad21
...
@@ -495,45 +495,16 @@ namespace dlib
...
@@ -495,45 +495,16 @@ namespace dlib
requires
requires
- item contains float values
- item contains float values
ensures
ensures
- #num_samples() == item.nr()
- if (num_samples() == item.nr() && k()*nr()*nc() == item.nc()) then
- #k() == item.nc()
- the dimensions of this tensor are not changed
- #nr() == 1
- else
- #nc() == 1
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Assigns item to *this tensor by performing:
- Assigns item to *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) = item;
set_ptrm(host(), num_samples(), k()*nr()*nc()) = item;
!*/
!*/
template
<
typename
EXP
>
resizable_tensor
&
operator
+=
(
const
matrix_exp
<
EXP
>&
item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Adds item to *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) += item;
!*/
template
<
typename
EXP
>
resizable_tensor
&
operator
-=
(
const
matrix_exp
<
EXP
>&
item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Subtracts item from *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) -= item;
!*/
};
};
void
serialize
(
const
tensor
&
item
,
std
::
ostream
&
out
);
void
serialize
(
const
tensor
&
item
,
std
::
ostream
&
out
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment