Skip to content

Commit 2052f1e

Browse files
authored
[Unify Tensors PR #8] Merged Tensor into DenseTensor, test=allcases (PaddlePaddle#38914)
* Merged LoDTensor with Tensor,test=allcases * Patched python level LoDTensor * Patched python level LoDTensor * Merge Tensor into DenseTensor * Fixed namespace issues,test=allcases * Fixed merge issues * Fixed inference issues * Fixed NPU test issues * Fixed merge issues
1 parent bfacd70 commit 2052f1e

File tree

270 files changed

+1212
-982
lines changed

Some content is hidden

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

270 files changed

+1212
-982
lines changed

paddle/fluid/distributed/fleet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ limitations under the License. */
3636

3737
namespace paddle {
3838
namespace framework {
39-
class Tensor;
4039
class Scope;
4140
class SelectedRows;
4241
class Variable;

paddle/fluid/distributed/fleet_executor/dist_model.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ bool DistModel::LoadParameters() {
145145
return true;
146146
}
147147

148-
void DistModel::Run(const std::vector<framework::Tensor> &input_data,
149-
std::vector<framework::Tensor> *output_data) {
148+
void DistModel::Run(const std::vector<paddle::framework::Tensor> &input_data,
149+
std::vector<paddle::framework::Tensor> *output_data) {
150150
/* TODO(fleet exe dev): implement this funct */
151151
}
152152

paddle/fluid/distributed/fleet_executor/dist_model.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
#include <vector>
1919

2020
#include "paddle/fluid/distributed/fleet_executor/fleet_executor_desc.pb.h"
21+
#include "paddle/fluid/framework/tensor.h"
2122
#include "paddle/fluid/platform/macros.h"
2223
#include "paddle/fluid/platform/place.h"
2324

2425
namespace paddle {
2526
namespace framework {
2627
class ProgramDesc;
2728
class Scope;
28-
class Tensor;
2929
}
3030

3131
namespace distributed {
@@ -45,8 +45,8 @@ class DistModel {
4545
public:
4646
explicit DistModel(const DistModelConfig& config) : config_(config) {}
4747
bool Init();
48-
void Run(const std::vector<framework::Tensor>& input_data,
49-
std::vector<framework::Tensor>* output_data);
48+
void Run(const std::vector<paddle::framework::Tensor>& input_data,
49+
std::vector<paddle::framework::Tensor>* output_data);
5050
~DistModel() = default;
5151

5252
private:

paddle/fluid/distributed/service/brpc_utils.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ limitations under the License. */
2020
namespace paddle {
2121
namespace framework {
2222
class Variable;
23-
class Tensor;
2423
} // namespace framework
2524
} // namespace paddle
2625

26+
namespace pten {
27+
class DenseTensor;
28+
} // namespace pten
29+
2730
namespace paddle {
2831
namespace distributed {
2932

paddle/fluid/distributed/test/brpc_service_dense_sgd_test.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ class PSClient;
3131
class PSServer;
3232
} // namespace distributed
3333
namespace framework {
34-
class Tensor;
3534
class Variable;
3635
} // namespace framework
3736
} // namespace paddle
3837

38+
namespace pten {
39+
class DenseTensor;
40+
} // namespace pten
41+
3942
namespace framework = paddle::framework;
4043
namespace platform = paddle::platform;
4144
namespace operators = paddle::operators;

paddle/fluid/distributed/test/brpc_service_sparse_sgd_test.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ class PSClient;
3232
class PSServer;
3333
} // namespace distributed
3434
namespace framework {
35-
class Tensor;
3635
class Variable;
3736
} // namespace framework
3837
} // namespace paddle
3938

39+
namespace pten {
40+
class DenseTensor;
41+
} // namespace pten
42+
4043
namespace framework = paddle::framework;
4144
namespace platform = paddle::platform;
4245
namespace operators = paddle::operators;

paddle/fluid/eager/legacy/prepared_operator.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ DECLARE_bool(use_mkldnn);
2929

3030
namespace paddle {
3131
namespace framework {
32-
class Tensor;
3332
class Variable;
3433
} // namespace framework
3534
namespace platform {
3635
class DeviceContext;
3736
} // namespace platform
3837
} // namespace paddle
3938

39+
namespace pten {
40+
class DenseTensor;
41+
} // namespace pten
42+
4043
namespace egr {
4144
namespace legacy {
4245

paddle/fluid/framework/copy_same_tensor_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static bool CopySameTensorTestMain(const DDim &dims,
6868
if (sync_copy) {
6969
TensorCopySync(src_tensor, dst_place, &src_tensor);
7070
} else {
71-
TensorCopy(src_tensor, dst_place, &src_tensor);
71+
paddle::framework::TensorCopy(src_tensor, dst_place, &src_tensor);
7272
platform::DeviceContextPool::Instance().Get(src_place)->Wait();
7373
platform::DeviceContextPool::Instance().Get(dst_place)->Wait();
7474
}

paddle/fluid/framework/data_device_transform.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ void TransDataDevice(const Tensor &in, const platform::Place &dst_place,
2828

2929
// NOTE(zhiqiu): Special case for CPU->NPU, avoid stream sync.
3030
if (platform::is_cpu_place(in.place()) && platform::is_npu_place(dst_place)) {
31-
TensorCopy(in, dst_place,
32-
*platform::DeviceContextPool::Instance().Get(dst_place), out);
31+
paddle::framework::TensorCopy(
32+
in, dst_place, *platform::DeviceContextPool::Instance().Get(dst_place),
33+
out);
3334
return;
3435
}
3536

paddle/fluid/framework/data_device_transform.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ limitations under the License. */
2121
namespace paddle {
2222
namespace framework {
2323

24-
class Tensor;
25-
2624
void TransDataDevice(const Tensor& in, const platform::Place& dst_place,
2725
Tensor* out);
2826

0 commit comments

Comments
 (0)