Skip to content

Commit 1aeb6c5

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into add-mkldnn-to-paddle-lib
2 parents 269a62a + e528862 commit 1aeb6c5

File tree

15 files changed

+55
-43
lines changed

15 files changed

+55
-43
lines changed

cmake/external/snappy.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ ExternalProject_Add(
4747
-DCMAKE_INSTALL_LIBDIR:PATH=${SNAPPY_INSTALL_DIR}/lib
4848
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
4949
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
50-
BUILD_COMMAND make -j8
51-
INSTALL_COMMAND make install
5250
)
5351

5452
add_library(snappy STATIC IMPORTED GLOBAL)

cmake/external/snappystream.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ ExternalProject_Add(
4646
-DCMAKE_INSTALL_PREFIX:PATH=${SNAPPYSTREAM_INSTALL_DIR}
4747
-DCMAKE_INSTALL_LIBDIR:PATH=${SNAPPYSTREAM_INSTALL_DIR}/lib
4848
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
49-
BUILD_COMMAND make -j8
50-
INSTALL_COMMAND make install
5149
DEPENDS snappy
5250
)
5351

paddle/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ if(NOT WITH_FLUID_ONLY)
2424
endif()
2525

2626
add_subdirectory(testing)
27-
if(NOT MOBILE_INFERENCE AND NOT RPI)
27+
if(NOT MOBILE_INFERENCE AND NOT RPI AND NOT WITH_C_API)
2828
add_subdirectory(fluid)
2929
endif()

paddle/fluid/framework/data_type.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static DataTypeMap* InitDataTypeMap() {
5858
RegType(bool, proto::VarType::BOOL);
5959
RegType(size_t, proto::VarType::SIZE_T);
6060
RegType(int16_t, proto::VarType::INT16);
61+
RegType(uint8_t, proto::VarType::UINT8);
6162

6263
#undef RegType
6364
return retv;

paddle/fluid/framework/data_type.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) {
4747
case proto::VarType::BOOL:
4848
visitor.template operator()<bool>();
4949
break;
50+
case proto::VarType::UINT8:
51+
visitor.template operator()<uint8_t>();
52+
break;
53+
case proto::VarType::INT16:
54+
visitor.template operator()<int16_t>();
55+
break;
5056
default:
51-
PADDLE_THROW("Not supported");
57+
PADDLE_THROW("Not supported %d", type);
5258
}
5359
}
5460

paddle/fluid/framework/details/fetch_op_handle.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,18 @@ void FetchOpHandle::RunImpl() {
4848
WaitInputVarGenerated(platform::CPUPlace());
4949

5050
tensors_.resize(inputs_.size());
51-
auto *var_handle = static_cast<VarHandle *>(inputs_[0]);
52-
auto &var_name = var_handle->name_;
5351
platform::CPUPlace cpu;
5452
auto &scopes = *local_scopes_;
5553

56-
for (size_t i = 0; i < scopes.size(); ++i) {
57-
auto &scope = scopes[i];
58-
auto *var =
59-
scope->FindVar(kLocalExecScopeName)->Get<Scope *>()->FindVar(var_name);
54+
for (size_t i = 0; i < inputs_.size(); ++i) {
55+
auto *var_handle = static_cast<VarHandle *>(inputs_[i]);
56+
auto &scope = scopes.at(var_handle->scope_idx_);
57+
auto *var = scope->FindVar(kLocalExecScopeName)
58+
->Get<Scope *>()
59+
->FindVar(var_handle->name_);
6060
PADDLE_ENFORCE_NOT_NULL(var, "Cannot find variable %s in execution scope",
61-
var_name);
61+
var_handle->name_);
62+
6263
auto &t = var->Get<framework::LoDTensor>();
6364
if (platform::is_gpu_place(t.place())) {
6465
#ifdef PADDLE_WITH_CUDA

paddle/fluid/framework/framework.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ message VarType {
103103
FP64 = 6;
104104
// Tensor<size_t> is used in C++.
105105
SIZE_T = 19;
106+
UINT8 = 20;
106107

107108
// Other types that may need additional descriptions
108109
LOD_TENSOR = 7;

paddle/fluid/framework/lod_tensor_test.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,12 @@ TEST(LoD, CheckAbsLoD) {
228228
ASSERT_FALSE(CheckAbsLoD(abs_lod0));
229229
}
230230

231-
TEST(LoDTensor, RecordIO) {
231+
template <typename T>
232+
static void TestRecordIO() {
232233
LoDTensor tensor;
233-
int* tmp = tensor.mutable_data<int>(make_ddim({4, 5}), platform::CPUPlace());
234+
T* tmp = tensor.mutable_data<T>(make_ddim({4, 5}), platform::CPUPlace());
234235
for (int i = 0; i < 20; ++i) {
235-
tmp[i] = i;
236+
tmp[i] = static_cast<T>(i);
236237
}
237238

238239
std::stringstream* stream = new std::stringstream();
@@ -247,7 +248,7 @@ TEST(LoDTensor, RecordIO) {
247248

248249
auto assert_tensor_ok = [](const LoDTensor& tensor) {
249250
for (int i = 0; i < 20; ++i) {
250-
ASSERT_EQ(tensor.data<int>()[i], i);
251+
ASSERT_EQ(tensor.data<T>()[i], static_cast<T>(i));
251252
}
252253
};
253254

@@ -265,5 +266,13 @@ TEST(LoDTensor, RecordIO) {
265266
}
266267
}
267268

269+
TEST(LoDTensor, RecordIO) {
270+
TestRecordIO<int>();
271+
TestRecordIO<int16_t>();
272+
TestRecordIO<uint8_t>();
273+
TestRecordIO<float>();
274+
TestRecordIO<double>();
275+
}
276+
268277
} // namespace framework
269278
} // namespace paddle

paddle/fluid/framework/operator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ limitations under the License. */
3333
#include "paddle/fluid/framework/tensor.h"
3434
#include "paddle/fluid/platform/device_context.h"
3535
#include "paddle/fluid/platform/variant.h"
36-
#include "paddle/utils/Error.h"
3736

3837
namespace paddle {
3938
namespace framework {

paddle/fluid/operators/math/math_function.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ template struct SetConstant<platform::CPUDeviceContext, bool>;
3838
template struct Transpose<platform::CPUDeviceContext, double, RANK>; \
3939
template struct Transpose<platform::CPUDeviceContext, int, RANK>; \
4040
template struct Transpose<platform::CPUDeviceContext, int64_t, RANK>; \
41-
template struct Transpose<platform::CPUDeviceContext, bool, RANK>;
41+
template struct Transpose<platform::CPUDeviceContext, bool, RANK>; \
42+
template struct Transpose<platform::CPUDeviceContext, int16_t, RANK>; \
43+
template struct Transpose<platform::CPUDeviceContext, uint8_t, RANK>;
4244

4345
DEFINE_CPU_TRANS(1);
4446
DEFINE_CPU_TRANS(2);

0 commit comments

Comments
 (0)