Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Change size_t to int within for loop to fix windows build error #14740

Merged
merged 2 commits into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void MKLDNNQuantizedFullyConnectedForward(const nnvm::NodeAttrs &attrs,
int32_t *quantized_bias_ptr = quantized_bias.data().dptr<int32_t>();
size_t bias_size = bias.shape().Size();
#pragma omp parallel for num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount())
for (size_t i = 0; i < bias_size; ++i) {
for (int i = 0; i < static_cast<int>(bias_size); ++i) {
quantized_bias_ptr[i] = bias_ptr[i] * bias_int32_rescale;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/operator/subgraph/mkldnn/mkldnn_fc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void SgMKLDNNFCOp::Forward(const OpContext &ctx,
int32_t *quantized_bias_ptr = cached_bias_.data().dptr<int32_t>();
size_t bias_size = bias.shape().Size();
#pragma omp parallel for num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount())
for (size_t i = 0; i < bias_size; ++i) {
for (int i = 0; i < static_cast<int>(bias_size); ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the static_cat from size_t to int safety if the value of bias_size is large than the range of int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already changed to index_t.

quantized_bias_ptr[i] = bias_ptr[i] * bias_int32_rescale;
}
}
Expand Down