QueueOptions size var data types to size_t
authorDalmo Cirne <dalmo@clarifai.com>
Tue, 17 Apr 2018 20:46:06 +0000 (16:46 -0400)
committerDalmo Cirne <dalmo@clarifai.com>
Tue, 17 Apr 2018 20:46:06 +0000 (16:46 -0400)
QueueOptions' max_batch_size and max_enqueued_batches are positive quantities, and when compared, in the code, with unsigned member functions, a warning is raised. By changing the data type from int to size_t, not only the meaning of the member variables are more aligned with their intent, but also the comparisons are done between unsigned integers, thus fixing the warnings.

tensorflow/core/kernels/batching_util/shared_batch_scheduler.h

index b77289a..1394753 100644 (file)
@@ -135,7 +135,7 @@ class SharedBatchScheduler
     // (inclusive). If there is a need to quantize the batch sizes, i.e. only
     // submit batches whose size is in a small set of allowed sizes, that can be
     // done by adding padding in the process-batch callback.
-    int max_batch_size = 1000;
+    size_t max_batch_size = 1000;
 
     // If a task has been enqueued for this amount of time (in microseconds),
     // and a thread is available, the scheduler will immediately form a batch
@@ -156,7 +156,7 @@ class SharedBatchScheduler
     // If this limit is reached, Schedule() will return an UNAVAILABLE error.
     // See the class documentation above for guidelines on how to tune this
     // parameter.
-    int max_enqueued_batches = 10;
+    size_t max_enqueued_batches = 10;
   };
   Status AddQueue(const QueueOptions& options,
                   std::function<void(std::unique_ptr<Batch<TaskType>>)>
@@ -393,7 +393,7 @@ Status SharedBatchScheduler<TaskType>::AddQueue(
     std::function<void(std::unique_ptr<Batch<TaskType>>)>
         process_batch_callback,
     std::unique_ptr<BatchScheduler<TaskType>>* queue) {
-  if (options.max_batch_size <= 0) {
+  if (options.max_batch_size == 0) {
     return errors::InvalidArgument("max_batch_size must be positive; was ",
                                    options.max_batch_size);
   }