Ensure that trivial types are passed by value rather than reference

PiperOrigin-RevId: 361073616
Change-Id: I3225a33d06e966d86365c1869fb40f5916f279dd
This commit is contained in:
A. Unique TensorFlower 2021-03-04 22:04:24 -08:00 committed by TensorFlower Gardener
parent b813277fd5
commit 94e8691760
6 changed files with 13 additions and 13 deletions

View File

@ -49,7 +49,7 @@ struct DeleteNotifier {
TEST(RefcountingHashMapTest, PointerIdentity) {
RefcountingHashMap<int, int> m;
auto factory = [](const int&) { return absl::make_unique<int>(); };
auto factory = [](const int) { return absl::make_unique<int>(); };
std::shared_ptr<int> a = m.GetOrCreateIfAbsent(0, factory);
std::shared_ptr<int> b = m.GetOrCreateIfAbsent(0, factory);
std::shared_ptr<int> c = m.GetOrCreateIfAbsent(1, factory);
@ -59,14 +59,14 @@ TEST(RefcountingHashMapTest, PointerIdentity) {
TEST(RefcountingHashMapTest, DefaultInitialized) {
RefcountingHashMap<int, int> m;
auto factory = [](const int&) { return absl::make_unique<int>(); };
auto factory = [](const int) { return absl::make_unique<int>(); };
EXPECT_EQ(*m.GetOrCreateIfAbsent(42, factory), 0);
}
TEST(RefcountingHashMapTest, DeletesEagerly) {
RefcountingHashMap<int, DeleteNotifier> m;
bool deleted = false;
auto factory = [](const int&) { return absl::make_unique<DeleteNotifier>(); };
auto factory = [](const int) { return absl::make_unique<DeleteNotifier>(); };
auto handle = m.GetOrCreateIfAbsent(0, factory);
handle->fn = [&] { deleted = true; };
EXPECT_FALSE(deleted);
@ -76,7 +76,7 @@ TEST(RefcountingHashMapTest, DeletesEagerly) {
TEST(RefcountingHashMapTest, CustomFactory) {
RefcountingHashMap<int, int> m;
auto factory = [](const int& x) { return absl::make_unique<int>(x + 1); };
auto factory = [](const int x) { return absl::make_unique<int>(x + 1); };
EXPECT_EQ(*m.GetOrCreateIfAbsent(0, factory), 1);
EXPECT_EQ(*m.GetOrCreateIfAbsent(100, factory), 101);
}

View File

@ -59,7 +59,7 @@ llvm::ArrayRef<T> AsArrayRef(const std::vector<T>& vec) {
}
template <typename T>
llvm::ArrayRef<T> AsArrayRef(const absl::Span<const T>& slice) {
llvm::ArrayRef<T> AsArrayRef(const absl::Span<const T> slice) {
return llvm::ArrayRef<T>(slice.data(), slice.size());
}

View File

@ -71,7 +71,7 @@ class BatchNormalizationTest
CHECK_EQ(kY, input_array_.width());
}
XlaOp CheckShape(XlaBuilder* b, const XlaOp& operand,
XlaOp CheckShape(XlaBuilder* b, const XlaOp operand,
const Shape& expected_shape) const {
Shape actual_shape = b->GetShape(operand).ConsumeValueOrDie();
CHECK(ShapeUtil::Equal(expected_shape, actual_shape))

View File

@ -34,7 +34,7 @@ namespace {
class BroadcastSimpleTest : public ClientLibraryTestBase {
public:
XlaOp BuildBinOp(HloOpcode op, const XlaOp& lhs, const XlaOp& rhs,
XlaOp BuildBinOp(HloOpcode op, const XlaOp lhs, const XlaOp rhs,
XlaBuilder* builder) {
switch (op) {
case HloOpcode::kMinimum: {

View File

@ -69,7 +69,7 @@ class ComputeConstantTest : public ::testing::Test {
LOG(FATAL) << "invalid client_type value";
}
StatusOr<Literal> ComputeConstantLiteral(Client* client, const XlaOp& operand,
StatusOr<Literal> ComputeConstantLiteral(Client* client, const XlaOp operand,
XlaBuilder* builder,
Layout* output_layout = nullptr) {
TF_ASSIGN_OR_RETURN(auto subgraph, builder->BuildConstantSubGraph(operand));
@ -79,14 +79,14 @@ class ComputeConstantTest : public ::testing::Test {
}
template <class Scalar>
StatusOr<Scalar> ComputeConstantScalar(Client* client, const XlaOp& operand,
StatusOr<Scalar> ComputeConstantScalar(Client* client, const XlaOp operand,
XlaBuilder* builder) {
TF_ASSIGN_OR_RETURN(auto literal, ComputeConstantLiteral(client, operand,
builder, nullptr));
return literal.Get<Scalar>({});
}
bool IsConstant(const XlaOp& operand, XlaBuilder* builder) {
bool IsConstant(const XlaOp operand, XlaBuilder* builder) {
StatusOr<bool> result = builder->IsConstant(operand);
EXPECT_TRUE(result.ok()) << result.status();
return result.ok() ? result.ValueOrDie() : false;

View File

@ -69,7 +69,7 @@ class ReduceWindowTest : public ::testing::WithParamInterface<bool>,
public:
ReduceWindowTest() : builder_(TestName()) { set_use_bfloat16(GetParam()); }
void ReduceWindowAdd(const XlaOp& input,
void ReduceWindowAdd(const XlaOp input,
absl::Span<const int64> window_dimensions,
absl::Span<const int64> window_strides,
Padding padding) {
@ -80,7 +80,7 @@ class ReduceWindowTest : public ::testing::WithParamInterface<bool>,
window_dimensions, window_strides, padding);
}
void ReduceWindowMax(const XlaOp& input,
void ReduceWindowMax(const XlaOp input,
absl::Span<const int64> window_dimensions,
absl::Span<const int64> window_strides,
Padding padding) {
@ -91,7 +91,7 @@ class ReduceWindowTest : public ::testing::WithParamInterface<bool>,
window_dimensions, window_strides, padding);
}
void ReduceWindowMin(const XlaOp& input,
void ReduceWindowMin(const XlaOp input,
absl::Span<const int64> window_dimensions,
absl::Span<const int64> window_strides,
Padding padding) {