Fix constructor bug in mixed_vector

yu239-patch-1
Yu Yang 7 years ago
parent d38b869438
commit 82c33c61d9

@ -37,9 +37,8 @@ class Vector {
// Fill vector with value. The vector size is `count`.
explicit Vector(size_t count, const T& value = T()) {
if (count == 0) {
InitEmpty();
} else {
InitEmpty();
if (count != 0) {
resize(count);
T* ptr = begin();
for (size_t i = 0; i < count; ++i) {

@ -15,6 +15,7 @@
#include "glog/logging.h"
#include "gtest/gtest.h"
#include "mixed_vector.h"
#include "paddle/fluid/framework/mixed_vector.h"
#include "paddle/fluid/platform/gpu_info.h"
@ -91,3 +92,10 @@ TEST(mixed_vector, MultiGPU) {
ASSERT_EQ(tmp[i], i * 100);
}
}
TEST(mixed_vector, InitWithCount) {
paddle::framework::Vector<int> vec(10, 10);
for (int i = 0; i < 10; ++i) {
ASSERT_EQ(vec[i], 10);
}
}

Loading…
Cancel
Save