Use explicitly brace-initialized int64 values rather than LL suffixes to protect against situations where int64 is not long long.

PiperOrigin-RevId: 321062446
Change-Id: Id4e8a82f0ad7e3fa7cd7db3a61fddfaa81af9ca4
This commit is contained in:
A. Unique TensorFlower 2020-07-13 16:57:38 -07:00 committed by TensorFlower Gardener
parent 88ce07f6fc
commit a007c24de6
6 changed files with 49 additions and 47 deletions

View File

@ -830,10 +830,10 @@ TEST_F(FunctionLibraryRuntimeTest, ExpandInlineFunctions) {
{
Scope s = Scope::NewRootScope();
auto x = ops::_Arg(s.WithOpName("x"), DT_FLOAT, 0);
auto x4_x2_two = ops::Const<int64>(s.WithOpName("x4/x2/two"), 2LL);
auto x4_y_two = ops::Const<int64>(s.WithOpName("x4/y/two"), 2LL);
auto y_x2_two = ops::Const<int64>(s.WithOpName("y/x2/two"), 2LL);
auto y_y_two = ops::Const<int64>(s.WithOpName("y/y/two"), 2LL);
auto x4_x2_two = ops::Const<int64>(s.WithOpName("x4/x2/two"), int64{2});
auto x4_y_two = ops::Const<int64>(s.WithOpName("x4/y/two"), int64{2});
auto y_x2_two = ops::Const<int64>(s.WithOpName("y/x2/two"), int64{2});
auto y_y_two = ops::Const<int64>(s.WithOpName("y/y/two"), int64{2});
auto x4_x2_scale =
ops::Cast(s.WithOpName("x4/x2/scale"), x4_x2_two, DT_FLOAT);
auto x4_y_scale = ops::Cast(s.WithOpName("x4/y/scale"), x4_y_two, DT_FLOAT);
@ -876,10 +876,10 @@ TEST_F(FunctionLibraryRuntimeTest, ExpandInlineFunctions) {
{
Scope s = Scope::NewRootScope();
auto x = ops::_Arg(s.WithOpName("x"), DT_FLOAT, 0);
auto x4_x2_two = ops::Const<int64>(s.WithOpName("x4/x2/two"), 2LL);
auto x4_y_two = ops::Const<int64>(s.WithOpName("x4/y/two"), 2LL);
auto y_x2_two = ops::Const<int64>(s.WithOpName("y/x2/two"), 2LL);
auto y_y_two = ops::Const<int64>(s.WithOpName("y/y/two"), 2LL);
auto x4_x2_two = ops::Const<int64>(s.WithOpName("x4/x2/two"), int64{2});
auto x4_y_two = ops::Const<int64>(s.WithOpName("x4/y/two"), int64{2});
auto y_x2_two = ops::Const<int64>(s.WithOpName("y/x2/two"), int64{2});
auto y_y_two = ops::Const<int64>(s.WithOpName("y/y/two"), int64{2});
auto x4_x2_scale =
ops::Cast(s.WithOpName("x4/x2/scale"), x4_x2_two, DT_FLOAT);
auto x4_y_scale = ops::Cast(s.WithOpName("x4/y/scale"), x4_y_two, DT_FLOAT);
@ -957,7 +957,7 @@ TEST_F(FunctionLibraryRuntimeTest, ExpandInlineFunctionsWithInputControlEdges) {
s.WithOpName("Func/b/x2/input/_4").WithControlDependencies({func3}),
func1);
auto b_x2_two = ops::Const(
s.WithOpName("b/x2/two").WithControlDependencies({func3}), 2LL);
s.WithOpName("b/x2/two").WithControlDependencies({func3}), int64{2});
auto b_x2_scale = ops::Cast(s.WithOpName("b/x2/scale"), b_x2_two, DT_FLOAT);
auto b_x2_y = ops::Mul(s.WithOpName("b/x2/y"), func4, b_x2_scale);
auto func5 = ops::Identity(s.WithOpName("Func/b/x2/output/_5"), b_x2_y);
@ -968,7 +968,7 @@ TEST_F(FunctionLibraryRuntimeTest, ExpandInlineFunctionsWithInputControlEdges) {
s.WithOpName("Func/b/y/input/_7").WithControlDependencies({func6}),
func5);
auto b_y_two = ops::Const(
s.WithOpName("b/y/two").WithControlDependencies({func6}), 2LL);
s.WithOpName("b/y/two").WithControlDependencies({func6}), int64{2});
auto b_y_scale = ops::Cast(s.WithOpName("b/y/scale"), b_y_two, DT_FLOAT);
auto b_y_y = ops::Mul(s.WithOpName("b/y/y"), func7, b_y_scale);
auto func8 = ops::Identity(s.WithOpName("Func/b/y/output/_8"), b_y_y);
@ -1589,7 +1589,7 @@ TEST_F(FunctionLibraryRuntimeTest, Gradient_XTimesTwo) {
{
Scope s = Scope::NewRootScope();
auto x = ops::_Arg(s.WithOpName("x"), DT_FLOAT, 0);
auto two = ops::Const(s.WithOpName("two"), 2LL);
auto two = ops::Const(s.WithOpName("two"), int64{2});
auto scale = ops::Cast(s.WithOpName("scale"), two, DT_FLOAT);
auto y = ops::Mul(s.WithOpName("y"), x, scale);
auto ret = ops::_Retval(s.WithOpName("y_RetVal"), y, 0);
@ -1607,7 +1607,7 @@ TEST_F(FunctionLibraryRuntimeTest, Gradient_XTimesTwo) {
Scope s = Scope::NewRootScope();
auto x = ops::_Arg(s.WithOpName("x"), DT_FLOAT, 0);
auto func0 = ops::_Arg(s.WithOpName("Func/_0"), DT_FLOAT, 1);
auto two = ops::Const(s.WithOpName("two"), 2LL);
auto two = ops::Const(s.WithOpName("two"), int64{2});
auto scale = ops::Cast(s.WithOpName("scale"), two, DT_FLOAT);
auto y = ops::Mul(s.WithOpName("y"), x, scale);
NameAttrList fn0;

View File

@ -74,8 +74,10 @@ TEST(KernelDefBuilderTest, TypeConstraint) {
}
TEST(KernelDefBuilderTest, Int64Constraint) {
const KernelDef* def =
KernelDefBuilder("B").Device(DEVICE_GPU).AttrConstraint("T", 5ll).Build();
const KernelDef* def = KernelDefBuilder("B")
.Device(DEVICE_GPU)
.AttrConstraint("T", int64{5})
.Build();
KernelDef expected;
protobuf::TextFormat::ParseFromString(R"proto(
op: 'B'
@ -91,7 +93,7 @@ TEST(KernelDefBuilderTest, Int64Constraint) {
def = KernelDefBuilder("C")
.Device(DEVICE_GPU)
.AttrConstraint("U", gtl::ArraySlice<int64>{5ll, 17ll})
.AttrConstraint("U", gtl::ArraySlice<int64>{int64{5}, int64{17}})
.AttrConstraint("V", string("proto"))
.Build();

View File

@ -596,8 +596,8 @@ Status SnapshotDatasetV2Op::Dataset::Iterator::Writer::WriteMetadataFile(
experimental::SnapshotMetadataRecord metadata;
metadata.set_creation_timestamp(EnvTime::NowMicros());
metadata.set_graph_hash(strings::Printf("%llu", dataset()->hash_));
metadata.set_run_id(strings::Printf("%llu", run_id_));
metadata.set_graph_hash(strings::StrCat(dataset()->hash_));
metadata.set_run_id(strings::StrCat(run_id_));
metadata.set_version(kFileFormatVersion);
for (const auto& output_dtype : dataset()->output_dtypes()) {
metadata.add_dtype(output_dtype);

View File

@ -40,15 +40,15 @@ TEST(ConvertXPlaneToMemoryProfile, OneAllocatorMultiActivitiesTest) {
auto tf_executor_thread = host_plane_builder.GetOrCreateLine(0);
CreateXEvent(&host_plane_builder, &tf_executor_thread, "MemoryAllocation",
40000, 1000,
{{StatType::kBytesReserved, 2000LL},
{StatType::kBytesAllocated, 3000LL},
{StatType::kBytesAvailable, 5000LL},
{StatType::kPeakBytesInUse, 8500LL},
{StatType::kRequestedBytes, 200LL},
{StatType::kAllocationBytes, 256LL},
{StatType::kAddress, 222333LL},
{StatType::kStepId, -93746LL},
{StatType::kDataType, 1LL},
{{StatType::kBytesReserved, int64{2000}},
{StatType::kBytesAllocated, int64{3000}},
{StatType::kBytesAvailable, int64{5000}},
{StatType::kPeakBytesInUse, int64{8500}},
{StatType::kRequestedBytes, int64{200}},
{StatType::kAllocationBytes, int64{256}},
{StatType::kAddress, int64{222333}},
{StatType::kStepId, int64{-93746}},
{StatType::kDataType, int64{1}},
{StatType::kAllocatorName, "GPU_0_bfc"},
{StatType::kTfOp, "foo/bar"},
{StatType::kRegionType, "output"},
@ -56,30 +56,30 @@ TEST(ConvertXPlaneToMemoryProfile, OneAllocatorMultiActivitiesTest) {
CreateXEvent(&host_plane_builder, &tf_executor_thread, "MemoryDeallocation",
50000, 1000,
{{StatType::kBytesReserved, 2000LL},
{StatType::kBytesAllocated, 2744LL},
{StatType::kBytesAvailable, 5256LL},
{StatType::kPeakBytesInUse, 8500LL},
{StatType::kRequestedBytes, 200LL},
{StatType::kAllocationBytes, 256LL},
{StatType::kAddress, 222333LL},
{StatType::kStepId, 0LL},
{StatType::kDataType, 0LL},
{{StatType::kBytesReserved, int64{2000}},
{StatType::kBytesAllocated, int64{2744}},
{StatType::kBytesAvailable, int64{5256}},
{StatType::kPeakBytesInUse, int64{8500}},
{StatType::kRequestedBytes, int64{200}},
{StatType::kAllocationBytes, int64{256}},
{StatType::kAddress, int64{222333}},
{StatType::kStepId, int64{0}},
{StatType::kDataType, int64{0}},
{StatType::kAllocatorName, "GPU_0_bfc"},
{StatType::kRegionType, ""},
{StatType::kTensorShapes, ""}});
CreateXEvent(&host_plane_builder, &tf_executor_thread, "MemoryAllocation",
70000, 1000,
{{StatType::kBytesReserved, 2000LL},
{StatType::kBytesAllocated, 5000LL},
{StatType::kBytesAvailable, 3000LL},
{StatType::kPeakBytesInUse, 9500LL},
{StatType::kRequestedBytes, 300LL},
{StatType::kAllocationBytes, 300LL},
{StatType::kAddress, 345678LL},
{StatType::kStepId, -93746LL},
{StatType::kDataType, 9LL},
{{StatType::kBytesReserved, int64{2000}},
{StatType::kBytesAllocated, int64{5000}},
{StatType::kBytesAvailable, int64{3000}},
{StatType::kPeakBytesInUse, int64{9500}},
{StatType::kRequestedBytes, int64{300}},
{StatType::kAllocationBytes, int64{300}},
{StatType::kAddress, int64{345678}},
{StatType::kStepId, int64{-93746}},
{StatType::kDataType, int64{9}},
{StatType::kAllocatorName, "GPU_0_bfc"},
{StatType::kTfOp, "mul_grad/Sum"},
{StatType::kRegionType, "temp"},

View File

@ -83,7 +83,7 @@ TEST(GroupEventsTest, GroupGpuTraceTest) {
auto main_thread = host_plane_builder.GetOrCreateLine(0);
CreateXEvent(&host_plane_builder, &main_thread, "train", 0, 100,
{{StatType::kStepNum, kStepNum}, {StatType::kIsRoot, 1LL}});
{{StatType::kStepNum, kStepNum}, {StatType::kIsRoot, int64{1}}});
CreateXEvent(&host_plane_builder, &main_thread, HostEventType::kFunctionRun,
10, 90, {{StatType::kStepId, kStepId}});

View File

@ -32,7 +32,7 @@ TEST(TimespanTests, NonInstantSpanIncludesSingleTimeTests) {
XEventBuilder event_builder = xline_builder.AddEvent(
*xplane_builder.GetOrCreateEventMetadata("1st event"));
event_builder.AddStatValue(
*xplane_builder.GetOrCreateStatMetadata("int stat"), 1234LL);
*xplane_builder.GetOrCreateStatMetadata("int stat"), int64{1234});
event_builder.AddStatValue(
*xplane_builder.GetOrCreateStatMetadata("string stat"),
std::string("abc"));
@ -50,7 +50,7 @@ TEST(TimespanTests, NonInstantSpanIncludesSingleTimeTests) {
EXPECT_EQ(xevent.Name(), "1st event");
xevent.ForEachStat([&](const XStatVisitor& stat) {
if (stat.Name() == "int stat") {
EXPECT_EQ(stat.IntValue(), 1234LL);
EXPECT_EQ(stat.IntValue(), int64{1234});
num_stats++;
} else if (stat.Name() == "string stat") {
EXPECT_EQ(stat.StrOrRefValue(), "abc");