未验证 提交 13f57ec0 编写于 作者: H Huang Jiyi 提交者: GitHub

[phi decoupling] rm gradient_accumulator in phi (#50385)

* rm gradient_accumulator in phi

* update
上级 e15ef948
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/imperative/gradient_accumulator.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/backends/custom/fake_cpu_device.h" #include "paddle/phi/backends/custom/fake_cpu_device.h"
#include "paddle/phi/backends/device_manager.h" #include "paddle/phi/backends/device_manager.h"
...@@ -240,51 +238,6 @@ void TestCustomCCL(const paddle::platform::Place& place) { ...@@ -240,51 +238,6 @@ void TestCustomCCL(const paddle::platform::Place& place) {
stream); stream);
} }
void TestBlasAPI(const paddle::platform::Place& place) {
std::cout << "TestBlasAPI on " << place << std::endl;
if (paddle::platform::is_custom_place(place) == false) {
return;
}
auto device = phi::DeviceManager::GetDeviceWithPlace(place);
phi::stream::Stream stream(place, nullptr);
device->BlasAXPBY<float>(stream, 0, 1., nullptr, 1., nullptr);
paddle::framework::Variable var1;
paddle::framework::Variable var2;
std::vector<float> src_data(10, 1.0);
std::vector<float> dst_data(10, 0.0);
std::vector<float> result;
paddle::platform::CPUPlace src_place;
for (unsigned int i = 0; i < 10; i++) {
result.emplace_back(src_data[i] + dst_data[i]);
}
std::vector<int64_t> dims = {2, 5};
auto* src = var1.GetMutable<phi::DenseTensor>();
auto* dst = var2.GetMutable<phi::DenseTensor>();
src->Resize(phi::make_ddim(dims));
dst->Resize(phi::make_ddim(dims));
auto* src_mutable = src->mutable_data<float>(place);
auto* dst_mutable = dst->mutable_data<float>(place);
paddle::memory::Copy(place,
src_mutable,
src_place,
src_data.data(),
sizeof(float) * src_data.size());
paddle::memory::Copy(place,
dst_mutable,
src_place,
dst_data.data(),
sizeof(float) * dst_data.size());
paddle::imperative::TensorAdd<paddle::framework::Variable>(var1, &var2);
phi::DenseTensor rlt;
paddle::platform::CPUPlace rlt_place;
paddle::framework::TensorCopySync(*dst, rlt_place, &rlt);
}
TEST(CustomDevice, Tensor) { TEST(CustomDevice, Tensor) {
InitDevice(); InitDevice();
auto dev_types = phi::DeviceManager::GetAllDeviceTypes(); auto dev_types = phi::DeviceManager::GetAllDeviceTypes();
...@@ -299,7 +252,6 @@ TEST(CustomDevice, Tensor) { ...@@ -299,7 +252,6 @@ TEST(CustomDevice, Tensor) {
TestTensorShareDataWith(place); TestTensorShareDataWith(place);
TestTensorUtils(place); TestTensorUtils(place);
TestCustomCCL(place); TestCustomCCL(place);
TestBlasAPI(place);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册