diff --git a/paddle/fluid/framework/data_type.cc b/paddle/fluid/framework/data_type.cc index b9c90cb0c32f337ba82ce1eaa5b43199540491ef..b6b93cf422a60c1d8e9cb8b477efd562f9fe4758 100644 --- a/paddle/fluid/framework/data_type.cc +++ b/paddle/fluid/framework/data_type.cc @@ -58,6 +58,7 @@ static DataTypeMap* InitDataTypeMap() { RegType(bool, proto::VarType::BOOL); RegType(size_t, proto::VarType::SIZE_T); RegType(int16_t, proto::VarType::INT16); + RegType(uint8_t, proto::VarType::UINT8); #undef RegType return retv; diff --git a/paddle/fluid/framework/data_type.h b/paddle/fluid/framework/data_type.h index 4b9f572ec5f1cda71c8b8dd8fae54b42e9f16f7a..491413db8c8d66fd907801131e89d9303bdef9f2 100644 --- a/paddle/fluid/framework/data_type.h +++ b/paddle/fluid/framework/data_type.h @@ -47,8 +47,14 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) { case proto::VarType::BOOL: visitor.template operator()(); break; + case proto::VarType::UINT8: + visitor.template operator()(); + break; + case proto::VarType::INT16: + visitor.template operator()(); + break; default: - PADDLE_THROW("Not supported"); + PADDLE_THROW("Not supported %d", type); } } diff --git a/paddle/fluid/framework/framework.proto b/paddle/fluid/framework/framework.proto index d2558f111f49139b33f921f7260b41830279edc8..d35125fe8c3c8018c38650dc87b2b1474ded6058 100644 --- a/paddle/fluid/framework/framework.proto +++ b/paddle/fluid/framework/framework.proto @@ -103,6 +103,7 @@ message VarType { FP64 = 6; // Tensor is used in C++. SIZE_T = 19; + UINT8 = 20; // Other types that may need additional descriptions LOD_TENSOR = 7; diff --git a/paddle/fluid/framework/lod_tensor_test.cc b/paddle/fluid/framework/lod_tensor_test.cc index 77e5ec4c7dd14b7ebb6d606b8c401ee714259d40..2ceffc93319359683e87e7fec2d18784c9bf02f3 100644 --- a/paddle/fluid/framework/lod_tensor_test.cc +++ b/paddle/fluid/framework/lod_tensor_test.cc @@ -228,11 +228,12 @@ TEST(LoD, CheckAbsLoD) { ASSERT_FALSE(CheckAbsLoD(abs_lod0)); } -TEST(LoDTensor, RecordIO) { +template +static void TestRecordIO() { LoDTensor tensor; - int* tmp = tensor.mutable_data(make_ddim({4, 5}), platform::CPUPlace()); + T* tmp = tensor.mutable_data(make_ddim({4, 5}), platform::CPUPlace()); for (int i = 0; i < 20; ++i) { - tmp[i] = i; + tmp[i] = static_cast(i); } std::stringstream* stream = new std::stringstream(); @@ -247,7 +248,7 @@ TEST(LoDTensor, RecordIO) { auto assert_tensor_ok = [](const LoDTensor& tensor) { for (int i = 0; i < 20; ++i) { - ASSERT_EQ(tensor.data()[i], i); + ASSERT_EQ(tensor.data()[i], static_cast(i)); } }; @@ -265,5 +266,13 @@ TEST(LoDTensor, RecordIO) { } } +TEST(LoDTensor, RecordIO) { + TestRecordIO(); + TestRecordIO(); + TestRecordIO(); + TestRecordIO(); + TestRecordIO(); +} + } // namespace framework } // namespace paddle diff --git a/paddle/fluid/operators/math/math_function.cc b/paddle/fluid/operators/math/math_function.cc index d62ea387cc55c7399973b6f35bace491a49666dc..d39154c6f88d6d17c1719eb9a5b048211f4bb52b 100644 --- a/paddle/fluid/operators/math/math_function.cc +++ b/paddle/fluid/operators/math/math_function.cc @@ -38,7 +38,9 @@ template struct SetConstant; template struct Transpose; \ template struct Transpose; \ template struct Transpose; \ - template struct Transpose; + template struct Transpose; \ + template struct Transpose; \ + template struct Transpose; DEFINE_CPU_TRANS(1); DEFINE_CPU_TRANS(2);