|
|
|
@ -20,6 +20,7 @@ limitations under the License. */
|
|
|
|
|
#include "paddle/fluid/framework/data_type.h"
|
|
|
|
|
#include "paddle/fluid/framework/framework.pb.h"
|
|
|
|
|
#include "paddle/fluid/framework/lod_tensor.h"
|
|
|
|
|
#include "paddle/fluid/framework/var_type.h"
|
|
|
|
|
|
|
|
|
|
#include "paddle/fluid/memory/memcpy.h"
|
|
|
|
|
#include "paddle/fluid/memory/memory.h"
|
|
|
|
@ -68,9 +69,9 @@ std::ostream &operator<<(std::ostream &os, const LoDTensor &t) {
|
|
|
|
|
// only print first ten elements
|
|
|
|
|
int64_t size = t.numel() < 10 ? t.numel() : 10;
|
|
|
|
|
for (int64_t i = 0; i < size; ++i) {
|
|
|
|
|
if (t.type().hash_code() == typeid(float).hash_code()) {
|
|
|
|
|
if (IsType<float>(t.type())) {
|
|
|
|
|
os << t.data<float>()[i] << " ";
|
|
|
|
|
} else if (t.type().hash_code() == typeid(int64_t).hash_code()) {
|
|
|
|
|
} else if (IsType<int64_t>(t.type())) {
|
|
|
|
|
os << t.data<int64_t>()[i] << " ";
|
|
|
|
|
} else {
|
|
|
|
|
PADDLE_THROW("LoDTensor data type not in [float, int64_t]");
|
|
|
|
@ -384,7 +385,7 @@ void LoDTensor::MergeLoDTensor(
|
|
|
|
|
LoD new_lod = lod_tensors[0]->lod();
|
|
|
|
|
for (size_t i = 1; i < lod_tensors.size(); ++i) {
|
|
|
|
|
auto *t = lod_tensors[i];
|
|
|
|
|
PADDLE_ENFORCE_EQ(new_type.hash_code(), t->type().hash_code());
|
|
|
|
|
PADDLE_ENFORCE_EQ(new_type, t->type());
|
|
|
|
|
PADDLE_ENFORCE_EQ(new_layout, t->layout());
|
|
|
|
|
|
|
|
|
|
PADDLE_ENFORCE_EQ(framework::product(new_dim) / new_dim[0],
|
|
|
|
|