Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Franck Dary
macaon
Commits
04dd8e56
Commit
04dd8e56
authored
Jun 30, 2020
by
Franck Dary
Browse files
Corrected a bug where a tensor was not send to the correct device
parent
81aecb05
Changes
1
Hide whitespace changes
Inline
Side-by-side
torch_modules/src/ConfigDataset.cpp
View file @
04dd8e56
...
...
@@ -94,7 +94,7 @@ void ConfigDataset::Holder::reset()
nextIndexToGive
=
0
;
nbGiven
=
0
;
torch
::
load
(
loadedTensor
,
files
[
loadedTensorIndex
],
NeuralNetworkImpl
::
device
);
loadedTensor
=
torch
::
index_select
(
loadedTensor
,
0
,
torch
::
randperm
(
loadedTensor
.
size
(
0
),
at
::
kLong
));
loadedTensor
=
torch
::
index_select
(
loadedTensor
,
0
,
torch
::
randperm
(
loadedTensor
.
size
(
0
),
torch
::
TensorOptions
(
at
::
kLong
).
device
(
NeuralNetworkImpl
::
device
)
));
}
c10
::
optional
<
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
std
::
string
>>
ConfigDataset
::
Holder
::
get_batch
(
std
::
size_t
batchSize
)
...
...
@@ -108,7 +108,7 @@ c10::optional<std::tuple<torch::Tensor,torch::Tensor,std::string>> ConfigDataset
return
c10
::
optional
<
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
std
::
string
>>
();
nextIndexToGive
=
0
;
torch
::
load
(
loadedTensor
,
files
[
loadedTensorIndex
],
NeuralNetworkImpl
::
device
);
loadedTensor
=
torch
::
index_select
(
loadedTensor
,
0
,
torch
::
randperm
(
loadedTensor
.
size
(
0
),
at
::
kLong
));
loadedTensor
=
torch
::
index_select
(
loadedTensor
,
0
,
torch
::
randperm
(
loadedTensor
.
size
(
0
),
torch
::
TensorOptions
(
at
::
kLong
).
device
(
NeuralNetworkImpl
::
device
)
));
}
int
nbElementsToGive
=
std
::
min
<
int
>
(
batchSize
,
loadedTensor
.
size
(
0
)
-
nextIndexToGive
);
...
...
Write
Preview
Supports
Markdown
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