Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 595437917
  • Loading branch information
gribozavr authored and copybara-github committed Jan 3, 2024
1 parent d4068d7 commit 0314a93
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 87 deletions.
2 changes: 1 addition & 1 deletion mediapipe/framework/basic_types_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<bool>);
MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<double>);
MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<float>);
MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<int>);
MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<int64>);
MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<int64_t>);
MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<std::string>);
MEDIAPIPE_REGISTER_GENERIC_TYPE(::std::vector<::std::vector<float>>);
MEDIAPIPE_REGISTER_GENERIC_TYPE_WITH_NAME(::std::string, "string");
2 changes: 1 addition & 1 deletion mediapipe/framework/calculator_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class CalculatorRunner {
mediapipe::Counter* GetCounter(const std::string& name);

// Returns all graph counters values.
std::map<std::string, int64> GetCountersValues();
std::map<std::string, int64_t> GetCountersValues();

private:
static const char kSourcePrefix[];
Expand Down
4 changes: 2 additions & 2 deletions mediapipe/framework/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef MEDIAPIPE_FRAMEWORK_COUNTER_H_
#define MEDIAPIPE_FRAMEWORK_COUNTER_H_

#include "mediapipe/framework/port/integral_types.h"
#include <cstdint>

namespace mediapipe {

Expand All @@ -28,7 +28,7 @@ class Counter {

virtual void Increment() = 0;
virtual void IncrementBy(int amount) = 0;
virtual int64 Get() = 0;
virtual int64_t Get() = 0;
};

} // namespace mediapipe
Expand Down
4 changes: 2 additions & 2 deletions mediapipe/framework/counter_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define MEDIAPIPE_FRAMEWORK_COUNTER_FACTORY_H_

#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
Expand All @@ -25,7 +26,6 @@
#include "absl/time/time.h"
#include "mediapipe/framework/counter.h"
#include "mediapipe/framework/port.h"
#include "mediapipe/framework/port/integral_types.h"
#include "mediapipe/framework/port/map_util.h"

namespace mediapipe {
Expand Down Expand Up @@ -66,7 +66,7 @@ class CounterSet {
Counter* Get(const std::string& name);

// Retrieves all counters names and current values from the internal map.
std::map<std::string, int64> GetCountersValues() ABSL_LOCKS_EXCLUDED(mu_);
std::map<std::string, int64_t> GetCountersValues() ABSL_LOCKS_EXCLUDED(mu_);

private:
absl::Mutex mu_;
Expand Down
64 changes: 32 additions & 32 deletions mediapipe/framework/deps/mathutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#define MEDIAPIPE_DEPS_MATHUTIL_H_

#include <cmath>
#include <cstdint>
#include <limits>
#include <type_traits>

#include "absl/log/absl_check.h"
#include "mediapipe/framework/port/integral_types.h"

namespace mediapipe {

Expand Down Expand Up @@ -189,114 +189,114 @@ class MathUtil {
// directly.
// --------------------------------------------------------------------

static int32 FastIntRound(double x) {
static int32_t FastIntRound(double x) {
#if defined __GNUC__ && (defined __i386__ || defined __SSE2__ || \
defined __aarch64__ || defined __powerpc64__)
#if defined __AVX__
// AVX.
int32 result;
int32_t result;
__asm__ __volatile__(
"vcvtsd2si %1, %0"
: "=r"(result) // Output operand is a register
: "xm"(x)); // Input operand is an xmm register or memory
return result;
#elif defined __SSE2__
// SSE2.
int32 result;
int32_t result;
__asm__ __volatile__(
"cvtsd2si %1, %0"
: "=r"(result) // Output operand is a register
: "xm"(x)); // Input operand is an xmm register or memory
return result;
#elif defined __i386__
// FPU stack. Adapted from /usr/include/bits/mathinline.h.
int32 result;
int32_t result;
__asm__ __volatile__("fistpl %0"
: "=m"(result) // Output operand is a memory location
: "t"(x) // Input operand is top of FP stack
: "st"); // Clobbers (pops) top of FP stack
return result;
#elif defined __aarch64__
int64 result;
int64_t result;
__asm__ __volatile__("fcvtns %d0, %d1"
: "=w"(result) // Vector floating point register
: "w"(x) // Vector floating point register
: /* No clobbers */);
return static_cast<int32>(result);
return static_cast<int32_t>(result);
#elif defined __powerpc64__
int64 result;
int64_t result;
__asm__ __volatile__("fctid %0, %1"
: "=d"(result)
: "d"(x)
: /* No clobbers */);
return result;
#endif // defined __powerpc64__
#else
return Round<int32>(x);
return Round<int32_t>(x);
#endif // if defined __GNUC__ && ...
}

static int32 FastIntRound(float x) {
static int32_t FastIntRound(float x) {
#if defined __GNUC__ && (defined __i386__ || defined __SSE2__ || \
defined __aarch64__ || defined __powerpc64__)
#if defined __AVX__
// AVX.
int32 result;
int32_t result;
__asm__ __volatile__(
"vcvtss2si %1, %0"
: "=r"(result) // Output operand is a register
: "xm"(x)); // Input operand is an xmm register or memory
return result;
#elif defined __SSE2__
// SSE2.
int32 result;
int32_t result;
__asm__ __volatile__(
"cvtss2si %1, %0"
: "=r"(result) // Output operand is a register
: "xm"(x)); // Input operand is an xmm register or memory
return result;
#elif defined __i386__
// FPU stack. Adapted from /usr/include/bits/mathinline.h.
int32 result;
int32_t result;
__asm__ __volatile__("fistpl %0"
: "=m"(result) // Output operand is a memory location
: "t"(x) // Input operand is top of FP stack
: "st"); // Clobbers (pops) top of FP stack
return result;
#elif defined __aarch64__
int64 result;
int64_t result;
__asm__ __volatile__("fcvtns %s0, %s1"
: "=w"(result) // Vector floating point register
: "w"(x) // Vector floating point register
: /* No clobbers */);
return static_cast<int32>(result);
return static_cast<int32_t>(result);
#elif defined __powerpc64__
uint64 output;
uint64_t output;
__asm__ __volatile__("fctiw %0, %1"
: "=d"(output)
: "f"(x)
: /* No clobbers */);
return bit_cast<int32>(static_cast<uint32>(output >> 32));
return bit_cast<int32_t>(static_cast<uint32_t>(output >> 32));
#endif // defined __powerpc64__
#else
return Round<int32>(x);
return Round<int32_t>(x);
#endif // if defined __GNUC__ && ...
}

static int64 FastInt64Round(double x) {
static int64_t FastInt64Round(double x) {
#if defined __GNUC__ && (defined __i386__ || defined __x86_64__ || \
defined __aarch64__ || defined __powerpc64__)
#if defined __AVX__
// AVX.
int64 result;
int64_t result;
__asm__ __volatile__(
"vcvtsd2si %1, %0"
: "=r"(result) // Output operand is a register
: "xm"(x)); // Input operand is an xmm register or memory
return result;
#elif defined __x86_64__
// SSE2.
int64 result;
int64_t result;
__asm__ __volatile__(
"cvtsd2si %1, %0"
: "=r"(result) // Output operand is a register
Expand All @@ -305,7 +305,7 @@ class MathUtil {
#elif defined __i386__
// There is no CVTSD2SI in i386 to produce a 64 bit int, even with SSE2.
// FPU stack. Adapted from /usr/include/bits/mathinline.h.
int64 result;
int64_t result;
__asm__ __volatile__("fistpll %0"
: "=m"(result) // Output operand is a memory location
: "t"(x) // Input operand is top of FP stack
Expand All @@ -314,32 +314,32 @@ class MathUtil {
#elif defined __aarch64__
// Floating-point convert to signed integer,
// rounding to nearest with ties to even.
int64 result;
int64_t result;
__asm__ __volatile__("fcvtns %d0, %d1"
: "=w"(result)
: "w"(x)
: /* No clobbers */);
return result;
#elif defined __powerpc64__
int64 result;
int64_t result;
__asm__ __volatile__("fctid %0, %1"
: "=d"(result)
: "d"(x)
: /* No clobbers */);
return result;
#endif // if defined __powerpc64__
#else
return Round<int64>(x);
return Round<int64_t>(x);
#endif // if defined __GNUC__ && ...
}

static int64 FastInt64Round(float x) {
static int64_t FastInt64Round(float x) {
return FastInt64Round(static_cast<double>(x));
}

static int32 FastIntRound(long double x) { return Round<int32>(x); }
static int32_t FastIntRound(long double x) { return Round<int32_t>(x); }

static int64 FastInt64Round(long double x) { return Round<int64>(x); }
static int64_t FastInt64Round(long double x) { return Round<int64_t>(x); }

// Absolute value of the difference between two numbers.
// Works correctly for signed types and special floating point values.
Expand Down Expand Up @@ -380,22 +380,22 @@ class MathUtil {
// partial specialization of templatized functions.

template <>
inline int32 MathUtil::Round<int32, float>(float x) {
inline int32_t MathUtil::Round<int32_t, float>(float x) {
return FastIntRound(x);
}

template <>
inline int32 MathUtil::Round<int32, double>(double x) {
inline int32_t MathUtil::Round<int32_t, double>(double x) {
return FastIntRound(x);
}

template <>
inline int64 MathUtil::Round<int64, float>(float x) {
inline int64_t MathUtil::Round<int64_t, float>(float x) {
return FastInt64Round(x);
}

template <>
inline int64 MathUtil::Round<int64, double>(double x) {
inline int64_t MathUtil::Round<int64_t, double>(double x) {
return FastInt64Round(x);
}

Expand Down
4 changes: 2 additions & 2 deletions mediapipe/framework/deps/numbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

namespace mediapipe {
ABSL_MUST_USE_RESULT inline std::string SimpleDtoa(double d) {
if (static_cast<double>(static_cast<int64>(d)) == d) {
return absl::StrCat(static_cast<int64>(d));
if (static_cast<double>(static_cast<int64_t>(d)) == d) {
return absl::StrCat(static_cast<int64_t>(d));
} else {
return absl::StrCat(d);
}
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/framework/deps/point2.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Point2 {
Coords c_; // coordinates
};

typedef Point2<uint8> Point2_b;
typedef Point2<uint8_t> Point2_b;
typedef Point2<int> Point2_i;
typedef Point2<float> Point2_f;
typedef Point2<double> Point2_d;
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/framework/deps/random_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RandomBase {

virtual float RandFloat() { return 0; }
virtual int UnbiasedUniform(int n) { return 0; }
virtual uint64 UnbiasedUniform64(uint64 n) { return 0; }
virtual uint64_t UnbiasedUniform64(uint64_t n) { return 0; }
};

#endif // MEDIAPIPE_DEPS_RANDOM_BASE_H_
2 changes: 1 addition & 1 deletion mediapipe/framework/deps/rectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ std::ostream& operator<<(std::ostream& out, const Rectangle<T>& r) {
template <typename T>
class Rectangle;

typedef Rectangle<uint8> Rectangle_b;
typedef Rectangle<uint8_t> Rectangle_b;
typedef Rectangle<int> Rectangle_i;
typedef Rectangle<float> Rectangle_f;
typedef Rectangle<double> Rectangle_d;
Expand Down
5 changes: 3 additions & 2 deletions mediapipe/framework/deps/safe_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <limits.h>

#include <cstdint>
#include <limits>
#include <type_traits>

Expand Down Expand Up @@ -228,7 +229,7 @@ class SafeIntStrongIntValidator {
}
}
template <typename T>
static void ValidateLeftShift(T lhs, int64 rhs) {
static void ValidateLeftShift(T lhs, int64_t rhs) {
if (std::numeric_limits<T>::is_signed) {
// Signed types only.
if (lhs < 0) {
Expand All @@ -247,7 +248,7 @@ class SafeIntStrongIntValidator {
}
}
template <typename T>
static void ValidateRightShift(T lhs, int64 rhs) {
static void ValidateRightShift(T lhs, int64_t rhs) {
if (std::numeric_limits<T>::is_signed) {
// Signed types only.
if (lhs < 0) {
Expand Down
16 changes: 9 additions & 7 deletions mediapipe/framework/deps/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ class BasicVector {
static void Print(std::ostream& out, const U& v) {
out << v;
}
static void Print(std::ostream& out, uint8 v) { out << static_cast<int>(v); }
static void Print(std::ostream& out, uint8_t v) {
out << static_cast<int>(v);
}

// Ignores its arguments so that side-effects of variadic unpacking can occur.
static void Ignore(std::initializer_list<bool>) {}
Expand Down Expand Up @@ -540,20 +542,20 @@ class Vector4
VType c_[SIZE];
};

typedef Vector2<uint8> Vector2_b;
typedef Vector2<int16> Vector2_s;
typedef Vector2<uint8_t> Vector2_b;
typedef Vector2<int16_t> Vector2_s;
typedef Vector2<int> Vector2_i;
typedef Vector2<float> Vector2_f;
typedef Vector2<double> Vector2_d;

typedef Vector3<uint8> Vector3_b;
typedef Vector3<int16> Vector3_s;
typedef Vector3<uint8_t> Vector3_b;
typedef Vector3<int16_t> Vector3_s;
typedef Vector3<int> Vector3_i;
typedef Vector3<float> Vector3_f;
typedef Vector3<double> Vector3_d;

typedef Vector4<uint8> Vector4_b;
typedef Vector4<int16> Vector4_s;
typedef Vector4<uint8_t> Vector4_b;
typedef Vector4<int16_t> Vector4_s;
typedef Vector4<int> Vector4_i;
typedef Vector4<float> Vector4_f;
typedef Vector4<double> Vector4_d;
Expand Down
Loading

0 comments on commit 0314a93

Please sign in to comment.