diff options
author | A. Unique TensorFlower <nobody@tensorflow.org> | 2016-03-17 21:42:37 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-03-18 08:48:14 -0700 |
commit | f4686d27a705bd547b828693462714d31bfd21ce (patch) | |
tree | 9d5ab2b7d1229fd68c1ca16c8725411173c89b9d /tensorflow/core/util/work_sharder.cc | |
parent | 200fa5fb0be1523f828014ae8f3ca28099cc942a (diff) |
Fix a static_cast overflow in WorkSharder Shard impl.
Change: 117520810
Diffstat (limited to 'tensorflow/core/util/work_sharder.cc')
-rw-r--r-- | tensorflow/core/util/work_sharder.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tensorflow/core/util/work_sharder.cc b/tensorflow/core/util/work_sharder.cc index dfc2c04baa..046d69a939 100644 --- a/tensorflow/core/util/work_sharder.cc +++ b/tensorflow/core/util/work_sharder.cc @@ -39,8 +39,10 @@ void Shard(int num_workers, thread::ThreadPool* workers, int64 total, // much. Let us assume each cost unit is 1ns, kMinCostPerShard=10000 // is 10us. static const int64 kMinCostPerShard = 10000; - const int num_shards = std::max( - 1, std::min<int>(num_workers, total * cost_per_unit / kMinCostPerShard)); + const int num_shards = + std::max<int>(1, std::min(static_cast<int64>(num_workers), + total * cost_per_unit / kMinCostPerShard)); + // Each shard contains up to "block_size" units. [0, total) is sharded // into: // [0, block_size), [block_size, 2*block_size), ... |