Skip to content

Commit

Permalink
Replace int64 with int64_t and uint64 with uint64_t.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 402347161
  • Loading branch information
lilao authored and tensorflow-copybara committed Oct 11, 2021
1 parent 7934ef4 commit 21360c7
Show file tree
Hide file tree
Showing 83 changed files with 339 additions and 333 deletions.
6 changes: 3 additions & 3 deletions tensorflow_serving/batching/batch_scheduler_retrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class BatchSchedulerRetrier : public BatchScheduler<TaskType> {
struct Options {
// The maximum amount of time to spend retrying 'wrapped_->Schedule()'
// calls, in microseconds.
int64 max_time_micros = 10 * 1000 /* 10 milliseconds */;
int64_t max_time_micros = 10 * 1000 /* 10 milliseconds */;

// The amount of time to pause between retry attempts, in microseconds.
int64 retry_delay_micros = 100;
int64_t retry_delay_micros = 100;

// The environment to use for time and sleeping.
Env* env = Env::Default();
Expand Down Expand Up @@ -94,7 +94,7 @@ Status BatchSchedulerRetrier<TaskType>::Schedule(
std::unique_ptr<TaskType>* task) {
Status status;

const uint64 start_time_micros = options_.env->NowMicros();
const uint64_t start_time_micros = options_.env->NowMicros();
for (;;) {
status = wrapped_->Schedule(task);
if (status.code() != error::UNAVAILABLE) {
Expand Down
20 changes: 10 additions & 10 deletions tensorflow_serving/batching/batching_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ string TensorSignatureDebugString(const TensorSignature& signature) {
}

struct HashTensorSignature {
uint64 operator()(const TensorSignature& signature) const {
uint64 hash = 0xDECAFCAFFE /* seed */;
uint64_t operator()(const TensorSignature& signature) const {
uint64_t hash = 0xDECAFCAFFE /* seed */;
for (const string& input_tensor : signature.input_tensors) {
hash = HashCombine(hash, std::hash<string>()(input_tensor));
}
Expand Down Expand Up @@ -585,7 +585,7 @@ Status BatchingSession::SplitOutputTensors(
batch->num_tasks());
}

std::vector<int64> task_sizes_plus_optional_padding;
std::vector<int64_t> task_sizes_plus_optional_padding;
task_sizes_plus_optional_padding.reserve(batch->num_tasks());
for (int i = 0; i < batch->num_tasks(); ++i) {
task_sizes_plus_optional_padding.push_back(batch->task(i).zeroth_dim_size);
Expand Down Expand Up @@ -709,7 +709,7 @@ void BatchingSession::ProcessBatch(
return;
}

const uint64 dequeue_time_micros = EnvTime::NowMicros();
const uint64_t dequeue_time_micros = EnvTime::NowMicros();

// Regardless of the outcome, we need to propagate the status to the
// individual tasks and signal that they are done. We use MakeCleanup() to
Expand All @@ -732,16 +732,16 @@ void BatchingSession::ProcessBatch(
// queue time alone, and find the latest task deadline which we'll use for the
// overall batch.
bool all_tasks_timeout_exceeded = true;
uint64 batch_deadline_micros = 0;
uint64_t batch_deadline_micros = 0;
for (int i = 0; i < batch->num_tasks(); ++i) {
const BatchingSessionTask& task = batch->task(i);
// If the caller doesn't populate RunOptions, the timeout is 0 by default.
// Interpret that as "no timeout" i.e. infinity.
const int64 task_timeout_micros =
const int64_t task_timeout_micros =
task.run_options.timeout_in_ms() <= 0
? INT_MAX
: task.run_options.timeout_in_ms() * 1000;
const uint64 task_deadline_micros =
const uint64_t task_deadline_micros =
task.enqueue_time_micros + task_timeout_micros;
if (task_deadline_micros > dequeue_time_micros) {
all_tasks_timeout_exceeded = false;
Expand Down Expand Up @@ -809,7 +809,7 @@ Status SplitInputTask(
int open_batch_remaining_slot, int max_batch_size,
std::vector<std::unique_ptr<BatchingSessionTask>>* output_tasks) {
BatchingSessionTask& input_task = *(*input_task_ptr);
const int64 input_task_size = input_task.size();
const int64_t input_task_size = input_task.size();

DCHECK_GT(input_task_size, 0);

Expand Down Expand Up @@ -884,9 +884,9 @@ Status SplitInputTask(
const internal::InputSplitMetadata input_split_metadata(
input_task_size, open_batch_remaining_slot, max_batch_size);

// Creates an array of int64 from an array of int, since `tensor::Split`
// Creates an array of int64_t from an array of int, since `tensor::Split`
// requires an array of int64.
const absl::FixedArray<int64> output_task_sizes(
const absl::FixedArray<int64_t> output_task_sizes(
input_split_metadata.task_sizes().begin(),
input_split_metadata.task_sizes().end());
const int num_batches = output_task_sizes.size();
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_serving/batching/batching_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct BatchingSessionTask : public BatchTask {
static std::string Name() { return "batching_session"; }

// Fields populated when a task is received.
uint64 enqueue_time_micros;
uint64_t enqueue_time_micros;
RunOptions run_options;
size_t zeroth_dim_size;
const std::vector<std::pair<string, Tensor>>* inputs;
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_serving/batching/batching_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace serving {
// It requires padding to be an array of elements that have fields
// "first" and "second".
struct OneDimPadding {
int64 first; // pad before
int64 second; // pad after
int64_t first; // pad before
int64_t second; // pad after
};

// Constructs array of paddings, where:
Expand Down
6 changes: 3 additions & 3 deletions tensorflow_serving/batching/streaming_batch_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ namespace internal {
// SingleTaskScheduler

SingleTaskScheduler::SingleTaskScheduler(Env* env, string thread_name,
uint64 no_tasks_wait_time_micros)
uint64_t no_tasks_wait_time_micros)
: env_(env),
thread_name_(std::move(thread_name)),
no_tasks_wait_time_micros_(no_tasks_wait_time_micros) {}

SingleTaskScheduler::~SingleTaskScheduler() { stop_.Notify(); }

void SingleTaskScheduler::Schedule(uint64 time_micros,
void SingleTaskScheduler::Schedule(uint64_t time_micros,
std::function<void()> closure) {
DCHECK_GE(time_micros, last_task_time_);
last_task_time_ = time_micros;
Expand All @@ -56,7 +56,7 @@ void SingleTaskScheduler::ThreadLogic() {
for (;;) {
// Sleep until the time specified in the current task, if any.
if (current_task) {
const uint64 now = env_->NowMicros();
const uint64_t now = env_->NowMicros();
if (current_task->time_micros > now) {
env_->SleepForMicroseconds(current_task->time_micros - now);
}
Expand Down
24 changes: 12 additions & 12 deletions tensorflow_serving/batching/streaming_batch_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class StreamingBatchScheduler : public BatchScheduler<TaskType> {
//
// A negative value means that no timeout will be enforced. This setting is
// useful in some test code.
int64 batch_timeout_micros = 0;
int64_t batch_timeout_micros = 0;

// The name to use for the pool of batch threads.
string thread_pool_name = "batch_threads";
Expand All @@ -151,7 +151,7 @@ class StreamingBatchScheduler : public BatchScheduler<TaskType> {

// How long SingleTaskScheduler should wait if there are no scheduled tasks,
// in microseconds.
uint64 no_tasks_wait_time_micros = 1000; // 1 millisecond
uint64_t no_tasks_wait_time_micros = 1000; // 1 millisecond
};
static Status Create(
const Options& options,
Expand Down Expand Up @@ -188,7 +188,7 @@ class StreamingBatchScheduler : public BatchScheduler<TaskType> {
// Takes a snapshot of 'open_batch_num_', and schedules an event with
// 'batch_closer_' to close it at time 'close_time_micros' if it is still open
// at that time.
void ScheduleCloseOfCurrentOpenBatch(uint64 close_time_micros)
void ScheduleCloseOfCurrentOpenBatch(uint64_t close_time_micros)
TF_EXCLUSIVE_LOCKS_REQUIRED(mu_);

const Options options_;
Expand All @@ -209,7 +209,7 @@ class StreamingBatchScheduler : public BatchScheduler<TaskType> {

// The sequence number of 'open_batch_'. Incremented each time 'open_batch_'
// is assigned to a new (non-null) batch object.
int64 open_batch_num_ TF_GUARDED_BY(mu_) = 0;
int64_t open_batch_num_ TF_GUARDED_BY(mu_) = 0;

// The number of batches "in progress", i.e. batches that have been started
// but for which the process-batch callback hasn't finished. Note that this
Expand Down Expand Up @@ -246,7 +246,7 @@ namespace internal {
class SingleTaskScheduler {
public:
SingleTaskScheduler(Env* env, string thread_name,
uint64 no_tasks_wait_time_micros);
uint64_t no_tasks_wait_time_micros);

// Blocks until the currently-set closure (if any) runs.
~SingleTaskScheduler();
Expand All @@ -256,7 +256,7 @@ class SingleTaskScheduler {
// cancels any closures provided in them (if they haven't already been run).
//
// IMPORTANT: 'time_micros' must be monotonically non-decreasing across calls.
void Schedule(uint64 time_micros, std::function<void()> closure);
void Schedule(uint64_t time_micros, std::function<void()> closure);

private:
// The code executed in 'thread_'. Looks for updated tasks, and executes them
Expand All @@ -271,7 +271,7 @@ class SingleTaskScheduler {

// The arguments to Schedule().
struct Task {
uint64 time_micros;
uint64_t time_micros;
std::function<void()> closure;
};

Expand All @@ -280,7 +280,7 @@ class SingleTaskScheduler {

// The time parameter passed in the most recent Schedule() invocation.
// Used to enforce monotonicity.
uint64 last_task_time_ = 0;
uint64_t last_task_time_ = 0;

// A notification for stopping the thread, during destruction.
Notification stop_;
Expand All @@ -292,7 +292,7 @@ class SingleTaskScheduler {
std::unique_ptr<Thread> thread_;

// How long to wait if there are no scheduled tasks, in microseconds.
const uint64 no_tasks_wait_time_micros_;
const uint64_t no_tasks_wait_time_micros_;

TF_DISALLOW_COPY_AND_ASSIGN(SingleTaskScheduler);
};
Expand Down Expand Up @@ -363,7 +363,7 @@ Status StreamingBatchScheduler<TaskType>::Schedule(
// If we are about to add the first task to a batch, schedule the batch to
// be closed after the timeout.
if (options_.batch_timeout_micros > 0 && open_batch_->empty()) {
const uint64 batch_deadline =
const uint64_t batch_deadline =
options_.env->NowMicros() + options_.batch_timeout_micros;
ScheduleCloseOfCurrentOpenBatch(batch_deadline);
}
Expand Down Expand Up @@ -433,13 +433,13 @@ void StreamingBatchScheduler<TaskType>::StartNewBatch() {

template <typename TaskType>
void StreamingBatchScheduler<TaskType>::ScheduleCloseOfCurrentOpenBatch(
uint64 close_time_micros) {
uint64_t close_time_micros) {
if (batch_closer_ == nullptr) {
batch_closer_.reset(new internal::SingleTaskScheduler(
options_.env, "batch_closer", options_.no_tasks_wait_time_micros));
}

const int64 batch_num_to_close = open_batch_num_;
const int64_t batch_num_to_close = open_batch_num_;
batch_closer_->Schedule(close_time_micros, [this, batch_num_to_close] {
{
mutex_lock l(this->mu_);
Expand Down
16 changes: 8 additions & 8 deletions tensorflow_serving/core/aspired_versions_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ Status ValidateAspiredVersions(
}

// Returns the set of version numbers in 'versions'.
std::set<int64> GetVersionNumbers(
std::set<int64_t> GetVersionNumbers(
const std::vector<ServableData<std::unique_ptr<Loader>>>& versions) {
std::set<int64> version_numbers;
std::set<int64_t> version_numbers;
for (const auto& version : versions) {
version_numbers.insert(version.id().version);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ Status AspiredVersionsManager::Create(
}

AspiredVersionsManager::AspiredVersionsManager(
int64 manage_state_interval_micros, Env* env,
int64_t manage_state_interval_micros, Env* env,
std::unique_ptr<AspiredVersionPolicy> aspired_version_policy,
std::unique_ptr<BasicManager> basic_manager)
: aspired_version_policy_(std::move(aspired_version_policy)),
Expand Down Expand Up @@ -256,14 +256,14 @@ void AspiredVersionsManager::ProcessAspiredVersionsRequest(
VLOG(1) << "Processing aspired versions request: " << servable_name << ": "
<< ServableVersionsDebugString(versions);

const std::set<int64> next_aspired_versions = GetVersionNumbers(versions);
const std::set<int64_t> next_aspired_versions = GetVersionNumbers(versions);

// We gather all the servables with the servable_name and
// 1. Add the current aspired version numbers to a set,
// 2. Set the aspired bool to false for all current servable harnesses which
// are not aspired.
std::set<int64> current_aspired_versions;
std::set<int64> current_aspired_versions_with_error;
std::set<int64_t> current_aspired_versions;
std::set<int64_t> current_aspired_versions_with_error;
const std::vector<ServableStateSnapshot<Aspired>> state_snapshots =
basic_manager_->GetManagedServableStateSnapshots<Aspired>(
string(servable_name));
Expand All @@ -287,7 +287,7 @@ void AspiredVersionsManager::ProcessAspiredVersionsRequest(
// We do a set_difference (A - B), on the next aspired versions and the
// current aspired versions to find the version numbers which need to be
// added the harness map.
std::set<int64> additions;
std::set<int64_t> additions;
std::set_difference(
next_aspired_versions.begin(), next_aspired_versions.end(),
current_aspired_versions.begin(), current_aspired_versions.end(),
Expand Down Expand Up @@ -338,7 +338,7 @@ bool AspiredVersionsManager::ContainsAnyReaspiredVersions(
const std::vector<ServableStateSnapshot<Aspired>> state_snapshots =
basic_manager_->GetManagedServableStateSnapshots<Aspired>(
string(servable_name));
const std::set<int64> version_numbers = GetVersionNumbers(versions);
const std::set<int64_t> version_numbers = GetVersionNumbers(versions);
for (const ServableStateSnapshot<Aspired>& state_snapshot : state_snapshots) {
if (!state_snapshot.additional_state->is_aspired &&
version_numbers.find(state_snapshot.id.version) !=
Expand Down
6 changes: 3 additions & 3 deletions tensorflow_serving/core/aspired_versions_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class AspiredVersionsManager : public Manager,
/// The periodicity, in microseconds, of the thread which manages the state
/// of the servables. Default: 100 milliseconds. If this is set less than or
/// equal to 0, we don't run this thread at all.
int64 manage_state_interval_micros = 100 * 1000;
int64_t manage_state_interval_micros = 100 * 1000;

/// EventBus to publish servable state changes. This is optional, if unset,
/// we don't publish.
Expand Down Expand Up @@ -125,7 +125,7 @@ class AspiredVersionsManager : public Manager,
/// The interval, in microseconds, between each servable load retry. If set
/// negative, we don't wait.
/// Default: 1 minute.
int64 load_retry_interval_micros = 1LL * 60 * 1000 * 1000;
int64_t load_retry_interval_micros = 1LL * 60 * 1000 * 1000;

// If true, and there are not multiple load threads, filesystem caches will
// be flushed after each servable is loaded. (Cache flush is skipped when
Expand Down Expand Up @@ -218,7 +218,7 @@ class AspiredVersionsManager : public Manager,
AspiredVersionsManager* manager);

AspiredVersionsManager(
int64 manage_state_interval_micros, Env* env,
int64_t manage_state_interval_micros, Env* env,
std::unique_ptr<AspiredVersionPolicy> aspired_version_policy,
std::unique_ptr<BasicManager> basic_manager);

Expand Down
Loading

0 comments on commit 21360c7

Please sign in to comment.