diff options
author | Michael Butler <butlermichael@google.com> | 2019-07-22 18:59:46 -0700 |
---|---|---|
committer | Slava Shklyaev <slavash@google.com> | 2019-08-23 11:42:41 +0100 |
commit | 43953b8f3976fe83c4b04322d4e855cba0688b1e (patch) | |
tree | 0a6719d328cfe7adeed49f814412e03dde303ad9 /nn/runtime/test/TestMemoryInternal.cpp | |
parent | a1846f57b824acda3616a0053bda3912b3f591ac (diff) | |
download | ml-43953b8f3976fe83c4b04322d4e855cba0688b1e.tar.gz |
clang-format for frameworks/ml/nn
This CL formats all of frameworks/ml/nn/* with the following commands:
$ $CLANG_DIR/clang-format --style=file -i `find $NNAPI_DIR -name "*.cpp"`
$ $CLANG_DIR/clang-format --style=file -i `find $NNAPI_DIR -name "*.h"`
where:
* "NNAPI_DIR" is "$ANDROID_BUILD_TOP/frameworks/ml/nn"
* "CLANG_DIR" is "$ANDROID_BUILD_TOP/prebuilts/clang/host/linux-x86/clang-stable/bin"
Bug: N/A
Test: mma
Change-Id: Idddbc7ecaeab76fb0bbee4250830333752a1f29b
Merged-In: Idddbc7ecaeab76fb0bbee4250830333752a1f29b
(cherry picked from commit 67e41a5467d7879b34f613069ade6cf61d5bd633)
Diffstat (limited to 'nn/runtime/test/TestMemoryInternal.cpp')
-rw-r--r-- | nn/runtime/test/TestMemoryInternal.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/nn/runtime/test/TestMemoryInternal.cpp b/nn/runtime/test/TestMemoryInternal.cpp index 755af09fd..8bba8253d 100644 --- a/nn/runtime/test/TestMemoryInternal.cpp +++ b/nn/runtime/test/TestMemoryInternal.cpp @@ -53,11 +53,11 @@ namespace { // (We can also get very unlucky and mask a memory leak by unrelated unmapping // somewhere else. This seems unlikely enough to not deal with.) class MemoryLeakTest : public ::testing::Test { -protected: + protected: void SetUp() override; void TearDown() override; -private: + private: size_t GetAshmemMappingsCount(); size_t mStartingMapCount = 0; @@ -77,7 +77,7 @@ void MemoryLeakTest::TearDown() { size_t MemoryLeakTest::GetAshmemMappingsCount() { std::ifstream mappingsStream("/proc/self/maps"); - if (! mappingsStream.good()) { + if (!mappingsStream.good()) { // errno is set by std::ifstream on Linux ADD_FAILURE() << "Failed to open /proc/self/maps: " << std::strerror(errno); return 0; @@ -85,9 +85,9 @@ size_t MemoryLeakTest::GetAshmemMappingsCount() { std::string line; int mapCount = 0; while (std::getline(mappingsStream, line)) { - if (line.find("/dev/ashmem") != std::string::npos) { - ++mapCount; - } + if (line.find("/dev/ashmem") != std::string::npos) { + ++mapCount; + } } return mapCount; } @@ -106,8 +106,8 @@ TEST_F(MemoryLeakTest, TestASharedMemory) { int weightsFd = ASharedMemory_create("weights", weightsSize); ASSERT_GT(weightsFd, -1); - uint8_t* weightsData = (uint8_t*)mmap(nullptr, weightsSize, PROT_READ | PROT_WRITE, - MAP_SHARED, weightsFd, 0); + uint8_t* weightsData = + (uint8_t*)mmap(nullptr, weightsSize, PROT_READ | PROT_WRITE, MAP_SHARED, weightsFd, 0); ASSERT_NE(weightsData, nullptr); memcpy(weightsData + offsetForMatrix2, matrix2, sizeof(matrix2)); memcpy(weightsData + offsetForMatrix3, matrix3, sizeof(matrix3)); @@ -139,8 +139,8 @@ TEST_F(MemoryLeakTest, TestASharedMemory) { constexpr size_t inputSize = offsetForMatrix1 + sizeof(Matrix3x4); int inputFd = ASharedMemory_create("input", inputSize); ASSERT_GT(inputFd, -1); - uint8_t* inputData = (uint8_t*)mmap(nullptr, inputSize, - PROT_READ | PROT_WRITE, MAP_SHARED, inputFd, 0); + uint8_t* inputData = + (uint8_t*)mmap(nullptr, inputSize, PROT_READ | PROT_WRITE, MAP_SHARED, inputFd, 0); ASSERT_NE(inputData, nullptr); memcpy(inputData + offsetForMatrix1, matrix1, sizeof(Matrix3x4)); WrapperMemory input(inputSize, PROT_READ, inputFd, 0); @@ -150,8 +150,8 @@ TEST_F(MemoryLeakTest, TestASharedMemory) { constexpr size_t outputSize = offsetForActual + sizeof(Matrix3x4); int outputFd = ASharedMemory_create("output", outputSize); ASSERT_GT(outputFd, -1); - uint8_t* outputData = (uint8_t*)mmap(nullptr, outputSize, - PROT_READ | PROT_WRITE, MAP_SHARED, outputFd, 0); + uint8_t* outputData = + (uint8_t*)mmap(nullptr, outputSize, PROT_READ | PROT_WRITE, MAP_SHARED, outputFd, 0); ASSERT_NE(outputData, nullptr); memset(outputData, 0, outputSize); WrapperMemory actual(outputSize, PROT_READ | PROT_WRITE, outputFd, 0); @@ -166,8 +166,9 @@ TEST_F(MemoryLeakTest, TestASharedMemory) { ASSERT_EQ(execution2.setOutputFromMemory(0, &actual, offsetForActual, sizeof(Matrix3x4)), WrapperResult::NO_ERROR); ASSERT_EQ(execution2.compute(), WrapperResult::NO_ERROR); - ASSERT_EQ(CompareMatrices(expected3, - *reinterpret_cast<Matrix3x4*>(outputData + offsetForActual)), 0); + ASSERT_EQ( + CompareMatrices(expected3, *reinterpret_cast<Matrix3x4*>(outputData + offsetForActual)), + 0); munmap(weightsData, weightsSize); munmap(inputData, inputSize); @@ -199,7 +200,7 @@ TEST_F(MemoryLeakTest, GetPointer) { ASSERT_TRUE(mem.isValid()); auto internalMem = reinterpret_cast<::android::nn::Memory*>(mem.get()); - uint8_t *dummy; + uint8_t* dummy; ASSERT_EQ(internalMem->getPointer(&dummy), ANEURALNETWORKS_NO_ERROR); (*dummy)++; } @@ -219,7 +220,7 @@ TEST_F(MemoryLeakTest, Instantiate) { ASSERT_TRUE(mem.isValid()); auto internalMem = reinterpret_cast<::android::nn::Memory*>(mem.get()); - uint8_t *dummy; + uint8_t* dummy; ASSERT_EQ(internalMem->getPointer(&dummy), ANEURALNETWORKS_NO_ERROR); close(fd); @@ -260,7 +261,8 @@ TEST_F(MemoryLeakTest, convTooLarge) { model.setOperandValue(act, act_init, sizeof(act_init)); int32_t stride_init[] = {1}; model.setOperandValue(stride, stride_init, sizeof(stride_init)); - model.addOperation(ANEURALNETWORKS_CONV_2D, {op1, op2, op3, pad0, pad0, pad0, pad0, stride, stride, act}, {op4}); + model.addOperation(ANEURALNETWORKS_CONV_2D, + {op1, op2, op3, pad0, pad0, pad0, pad0, stride, stride, act}, {op4}); // Inputs and outputs model.identifyInputsAndOutputs({op1}, {op4}); @@ -269,7 +271,7 @@ TEST_F(MemoryLeakTest, convTooLarge) { // Compilation WrapperCompilation compilation(&model); - ASSERT_EQ(WrapperResult::NO_ERROR,compilation.finish()); + ASSERT_EQ(WrapperResult::NO_ERROR, compilation.finish()); WrapperExecution execution(&compilation); // Set input and outputs @@ -283,6 +285,6 @@ TEST_F(MemoryLeakTest, convTooLarge) { ASSERT_EQ(WrapperResult::OP_FAILED, r); } -#endif // NNTEST_ONLY_PUBLIC_API +#endif // NNTEST_ONLY_PUBLIC_API } // end namespace |