diff options
author | Asim Shankar <ashankar@google.com> | 2016-11-14 11:48:24 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-11-14 12:31:30 -0800 |
commit | 786938758a39940ae0154834bfed9e21894afa28 (patch) | |
tree | 36a9e3dddb1d7a2ddffb37d9b9744342e5a35ba5 /tensorflow/c/c_api_test.cc | |
parent | 2a00221aecf8000420d73fd5937c01e154339f24 (diff) |
C API: Stick to a convention around use of size_t and int.
The types size_t and int were being used inconsistently
across different functions. This change documents the
convention and fixes a few functions up to ensure that
all functions adhere to it.
Not quite sure if this convention (in particular using
'int' for array indices, as opposed to say 'size_t')
is the best choice, but at least the choice has been
made consistently.
Change: 139100887
Diffstat (limited to 'tensorflow/c/c_api_test.cc')
-rw-r--r-- | tensorflow/c/c_api_test.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tensorflow/c/c_api_test.cc b/tensorflow/c/c_api_test.cc index 27a5a0991b..2b46c6f1e6 100644 --- a/tensorflow/c/c_api_test.cc +++ b/tensorflow/c/c_api_test.cc @@ -871,7 +871,7 @@ TEST(CAPI, ColocateWith) { EXPECT_EQ(1, m.list_size); EXPECT_EQ(TF_ATTR_STRING, m.type); void* values[1]; - int lens[1]; + size_t lens[1]; std::unique_ptr<char[]> storage(new char[m.total_size]); TF_OperationGetAttrStringList(add, tensorflow::kColocationAttrName, values, lens, 1, storage.get(), m.total_size, s); @@ -896,9 +896,9 @@ TF_Tensor* Int8Tensor(const int64_t* dims, int num_dims, const char* values) { void StringVectorToArrays(const std::vector<string>& v, std::unique_ptr<const void* []>* ptrs, - std::unique_ptr<int[]>* lens) { + std::unique_ptr<size_t[]>* lens) { ptrs->reset(new const void*[v.size()]); - lens->reset(new int[v.size()]); + lens->reset(new size_t[v.size()]); for (size_t i = 0; i < v.size(); ++i) { (*ptrs)[i] = v[i].data(); (*lens)[i] = v[i].size(); @@ -986,7 +986,7 @@ TEST_F(CApiAttributesTest, String) { TEST_F(CApiAttributesTest, StringList) { std::vector<string> list = {"bugs", "bunny", "duck"}; std::unique_ptr<const void* []> list_ptrs; - std::unique_ptr<int[]> list_lens; + std::unique_ptr<size_t[]> list_lens; StringVectorToArrays(list, &list_ptrs, &list_lens); int list_total_size = 0; for (const auto& s : list) { @@ -1002,7 +1002,7 @@ TEST_F(CApiAttributesTest, StringList) { EXPECT_TF_META("v", list.size(), TF_ATTR_STRING, list_total_size); std::unique_ptr<void* []> values(new void*[list.size()]); - std::unique_ptr<int[]> lens(new int[list.size()]); + std::unique_ptr<size_t[]> lens(new size_t[list.size()]); std::unique_ptr<char[]> storage(new char[list_total_size]); TF_OperationGetAttrStringList(oper, "v", values.get(), lens.get(), list.size(), storage.get(), list_total_size, @@ -1227,7 +1227,7 @@ TEST_F(CApiAttributesTest, TensorShapeProtoList) { proto.SerializeToString(&bytes2); std::unique_ptr<const void* []> list_ptrs; - std::unique_ptr<int[]> list_lens; + std::unique_ptr<size_t[]> list_lens; const std::vector<string> list = {bytes1, bytes2}; StringVectorToArrays(list, &list_ptrs, &list_lens); |