Skip to content

Commit 11bcb43

Browse files
committed
fix merge issue
2 parents a8b630c + 4f4abfa commit 11bcb43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+612
-465
lines changed

AUTHORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
|---|---|
33
| backyes | Yan-Fei Wang |
44
| beckett1124 | Bin Qi |
5-
| Canpio | Jia-Yi Feng |
5+
| JiayiFeng | Jia-Yi Feng |
66
| chengxiaohua1105 | Xiao-Hua Cheng |
77
| cxwangyi, yiwangbaidu, wangkuiyi | Yi Wang |
88
| cxysteven | Xing-Yi Cheng |

doc/templates/conf.py.cn.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ language = 'zh_CN'
8282

8383
# List of patterns, relative to source directory, that match files and
8484
# directories to ignore when looking for source files.
85-
exclude_patterns = ['_build', '**/*_en*', '*_en*']
85+
exclude_patterns = ['_build', '**/*_en*', '*_en*', 'api/*']
8686

8787
# The reST default role (used for this markup: `text`) to use for all
8888
# documents.

doc/templates/conf.py.en.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ language = None
8282

8383
# List of patterns, relative to source directory, that match files and
8484
# directories to ignore when looking for source files.
85-
exclude_patterns = ['_build', '**/*_cn*', '*_cn*']
85+
exclude_patterns = ['_build', '**/*_cn*', '*_cn*', 'api/*']
8686

8787
# The reST default role (used for this markup: `text`) to use for all
8888
# documents.

paddle/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ if(MOBILE_INFERENCE)
1111
else()
1212
add_subdirectory(pserver)
1313
add_subdirectory(trainer)
14-
add_subdirectory(string)
1514
add_subdirectory(scripts)
1615

1716
if(WITH_C_API)

paddle/fluid/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ add_subdirectory(framework)
44
add_subdirectory(operators)
55
add_subdirectory(pybind)
66
add_subdirectory(inference)
7+
add_subdirectory(string)

paddle/fluid/framework/ddim.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,5 +314,15 @@ DDim stride(const DDim& ddim) {
314314
}
315315
return framework::make_ddim(strides);
316316
}
317+
318+
DDim stride_numel(const framework::DDim& ddim) {
319+
std::vector<int64_t> strides(ddim.size());
320+
strides[ddim.size() - 1] = ddim[ddim.size() - 1];
321+
for (int i = ddim.size() - 2; i >= 0; --i) {
322+
strides[i] = strides[i + 1] * ddim[i];
323+
}
324+
return framework::make_ddim(strides);
325+
}
326+
317327
} // namespace framework
318328
} // namespace paddle

paddle/fluid/framework/ddim.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ DDim flatten_to_2d(const DDim& src, int num_col_dims);
125125
DDim flatten_to_1d(const DDim& src);
126126

127127
DDim stride(const DDim& ddim);
128+
129+
DDim stride_numel(const DDim& ddim);
128130
} // namespace framework
129131
} // namespace paddle
130132

paddle/fluid/framework/init.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License. */
2020
#include "paddle/fluid/framework/operator.h"
2121
#include "paddle/fluid/platform/device_context.h"
2222
#include "paddle/fluid/platform/place.h"
23-
#include "paddle/string/piece.h"
23+
#include "paddle/fluid/string/piece.h"
2424

2525
namespace paddle {
2626
namespace framework {

paddle/fluid/framework/mixed_vector.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ class Vector {
3737

3838
// Fill vector with value. The vector size is `count`.
3939
explicit Vector(size_t count, const T& value = T()) {
40-
if (count == 0) {
41-
InitEmpty();
42-
} else {
40+
InitEmpty();
41+
if (count != 0) {
4342
resize(count);
4443
T* ptr = begin();
4544
for (size_t i = 0; i < count; ++i) {
@@ -122,6 +121,10 @@ class Vector {
122121
const T* begin() const { return &this->operator[](0); }
123122
const T* end() const { return &this->operator[](size()); }
124123

124+
const T* cbegin() const { return begin(); }
125+
126+
const T* cend() const { return end(); }
127+
125128
const T& back() const {
126129
auto it = end();
127130
--it;
@@ -244,7 +247,9 @@ class Vector {
244247

245248
bool operator==(const Vector<T>& other) const {
246249
if (size() != other.size()) return false;
247-
for (auto it1 = begin(), it2 = other.begin(); it1 < end(); ++it1, ++it2) {
250+
auto it1 = cbegin();
251+
auto it2 = other.cbegin();
252+
for (; it1 < cend(); ++it1, ++it2) {
248253
if (*it1 != *it2) {
249254
return false;
250255
}

paddle/fluid/framework/mixed_vector_test.cu

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ TEST(mixed_vector, CPU_VECTOR) {
2626
for (int i = 0; i < 10; ++i) {
2727
tmp.push_back(i);
2828
}
29-
ASSERT_EQ(tmp.size(), 10);
29+
ASSERT_EQ(tmp.size(), 10UL);
3030
vec<int> tmp2;
3131
tmp2 = tmp;
32-
ASSERT_EQ(tmp2.size(), 10);
32+
ASSERT_EQ(tmp2.size(), 10UL);
3333
for (int i = 0; i < 10; ++i) {
3434
ASSERT_EQ(tmp2[i], i);
3535
ASSERT_EQ(tmp2[i], tmp[i]);
@@ -58,7 +58,7 @@ TEST(mixed_vector, GPU_VECTOR) {
5858
for (int i = 0; i < 10; ++i) {
5959
tmp.push_back(i);
6060
}
61-
ASSERT_EQ(tmp.size(), 10);
61+
ASSERT_EQ(tmp.size(), 10UL);
6262
paddle::platform::CUDAPlace gpu(0);
6363

6464
multiply_10<<<1, 1, 0, GetCUDAStream(gpu)>>>(tmp.MutableData(gpu));
@@ -79,7 +79,7 @@ TEST(mixed_vector, MultiGPU) {
7979
for (int i = 0; i < 10; ++i) {
8080
tmp.push_back(i);
8181
}
82-
ASSERT_EQ(tmp.size(), 10);
82+
ASSERT_EQ(tmp.size(), 10UL);
8383
paddle::platform::CUDAPlace gpu0(0);
8484
paddle::platform::SetDeviceId(0);
8585
multiply_10<<<1, 1, 0, GetCUDAStream(gpu0)>>>(tmp.MutableData(gpu0));
@@ -91,3 +91,10 @@ TEST(mixed_vector, MultiGPU) {
9191
ASSERT_EQ(tmp[i], i * 100);
9292
}
9393
}
94+
95+
TEST(mixed_vector, InitWithCount) {
96+
paddle::framework::Vector<int> vec(10, 10);
97+
for (int i = 0; i < 10; ++i) {
98+
ASSERT_EQ(vec[i], 10);
99+
}
100+
}

0 commit comments

Comments
 (0)