Skip to content

Commit

Permalink
Create shim targets for most commonly used TSL headers in preparation…
Browse files Browse the repository at this point in the history
… for updating users

PiperOrigin-RevId: 707667247
  • Loading branch information
ddunl authored and copybara-github committed Dec 18, 2024
1 parent dbb2be9 commit e40b7b1
Show file tree
Hide file tree
Showing 37 changed files with 74 additions and 8,190 deletions.
229 changes: 32 additions & 197 deletions tsl/platform/BUILD

Large diffs are not rendered by default.

649 changes: 0 additions & 649 deletions tsl/platform/env.cc

This file was deleted.

720 changes: 2 additions & 718 deletions tsl/platform/env.h

Large diffs are not rendered by default.

50 changes: 3 additions & 47 deletions tsl/platform/env_time.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2024 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -12,54 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_TSL_PLATFORM_ENV_TIME_H_
#define TENSORFLOW_TSL_PLATFORM_ENV_TIME_H_

#include <stdint.h>

#include "tsl/platform/types.h"

namespace tsl {

/// \brief An interface used by the tsl implementation to
/// access timer related operations.
class EnvTime {
public:
static constexpr uint64 kMicrosToPicos = 1000ULL * 1000ULL;
static constexpr uint64 kMicrosToNanos = 1000ULL;
static constexpr uint64 kMillisToMicros = 1000ULL;
static constexpr uint64 kMillisToNanos = 1000ULL * 1000ULL;
static constexpr uint64 kNanosToPicos = 1000ULL;
static constexpr uint64 kSecondsToMillis = 1000ULL;
static constexpr uint64 kSecondsToMicros = 1000ULL * 1000ULL;
static constexpr uint64 kSecondsToNanos = 1000ULL * 1000ULL * 1000ULL;

EnvTime() = default;
virtual ~EnvTime() = default;

/// \brief Returns the number of nano-seconds since the Unix epoch.
static uint64 NowNanos();

/// \brief Returns the number of micro-seconds since the Unix epoch.
static uint64 NowMicros() { return NowNanos() / kMicrosToNanos; }

/// \brief Returns the number of seconds since the Unix epoch.
static uint64 NowSeconds() { return NowNanos() / kSecondsToNanos; }

/// \brief A version of NowNanos() that may be overridden by a subclass.
virtual uint64 GetOverridableNowNanos() const { return NowNanos(); }

/// \brief A version of NowMicros() that may be overridden by a subclass.
virtual uint64 GetOverridableNowMicros() const {
return GetOverridableNowNanos() / kMicrosToNanos;
}

/// \brief A version of NowSeconds() that may be overridden by a subclass.
virtual uint64 GetOverridableNowSeconds() const {
return GetOverridableNowNanos() / kSecondsToNanos;
}
};

} // namespace tsl
#include "xla/tsl/platform/env_time.h"

#endif // TENSORFLOW_TSL_PLATFORM_ENV_TIME_H_
249 changes: 0 additions & 249 deletions tsl/platform/errors.cc

This file was deleted.

Loading

0 comments on commit e40b7b1

Please sign in to comment.