Skip to content

Commit

Permalink
abacus-aibox-906 remove the debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
HuangShiqing authored and jack603047588 committed Dec 1, 2023
1 parent 2174c3c commit f4e322f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 100 deletions.
2 changes: 1 addition & 1 deletion cmake/external/xpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ if (WITH_BOX_PS OR WITH_XPU_KP)
CACHE STRING "" FORCE)
#"https://klx-sdk-release-public.su.bcebos.com/xdnn/release/2.6.0.1/${XPU_XDNN_DIR_NAME}.tar.gz"
set(XPU_XDNN_URL
"https://klx-sdk-release-public.su.bcebos.com/xdnn_train/dev/paddlebox/20231115/${XPU_XDNN_DIR_NAME}.tar.gz"
"https://klx-sdk-release-public.su.bcebos.com/xdnn_train/dev/paddlebox/20231201/${XPU_XDNN_DIR_NAME}.tar.gz"
CACHE STRING "" FORCE)
set(SCALOPUS_URL
"https://klx-sdk-release-public.su.bcebos.com/xdnn_train/dev/paddlebox/20230306/scalopus.tar.gz"
Expand Down
99 changes: 0 additions & 99 deletions paddle/fluid/operators/index_select_op_xpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,6 @@ class IndexSelectXPUKernel : public framework::OpKernel<T> {
phi::DataType::INT32,
phi::DataType::INT64));

// static int target_id = std::getenv("HSQ_XPURT_TARGET_DEVICE")!=NULL ?
// std::stoi(std::string(std::getenv("HSQ_XPURT_TARGET_DEVICE"))) :
// 0;
// int dev_id = ctx.GetPlace().GetDeviceId();
// // if(dev_id == target_id) {
// // printf("[hsq] input shape: %d, %d\n", (int)x->dims()[0], (int)x->dims()[1]);
// // printf("[hsq] index_len: %d\n", index_len);
// // printf("[hsq] out shape: %d, %d\n", (int)out->dims()[0], (int)out->dims()[1]);
// // }

// auto cpu_device_ctx = platform::DeviceContextPool::Instance().Get(phi::CPUPlace());
// framework::ExecutionContext cpu_execution_ctx(ctx.GetOp(), ctx.scope(), *cpu_device_ctx, ctx.Context());

// LoDTensor x_cpu_copy;
// framework::TensorCopySync(*x, platform::CPUPlace(), &x_cpu_copy);
// LoDTensor index_cpu_copy;
// framework::TensorCopySync(*index, platform::CPUPlace(), &index_cpu_copy);
// LoDTensor out_cpu_copy;
// framework::TensorCopySync(*out, platform::CPUPlace(), &out_cpu_copy);

// if (index_type == phi::DataType::INT32) {
// IndexSelectInner<DeviceContext, T, int>(cpu_execution_ctx, &x_cpu_copy, index_cpu_copy, &out_cpu_copy, dim);
// } else if (index_type == phi::DataType::INT64) {
// IndexSelectInner<DeviceContext, T, int64_t>(cpu_execution_ctx, &x_cpu_copy, index_cpu_copy, &out_cpu_copy, dim);
// }

int r = -1;
std::vector<int> xshape = phi::vectorize<int>(x->dims());
if (index_type == phi::DataType::INT64) {
Expand All @@ -84,25 +58,6 @@ class IndexSelectXPUKernel : public framework::OpKernel<T> {
r = xpu::gather<T, int>(xpu_context, x_data, index_data, out_data, xshape, index_len, dim);
}

// LoDTensor out_ref_cpu_copy;
// framework::TensorCopySync(*out, platform::CPUPlace(), &out_ref_cpu_copy);
// bool correct = true;
// float diff = 1e-5;
// for (int i = 0; i < out_ref_cpu_copy.numel(); i++) {
// T* ref_data = out_ref_cpu_copy.data<T>();
// T* cpu_data = out_cpu_copy.data<T>();
// if(std::abs(*(ref_data + i) - *(cpu_data+i)) > diff) {
// correct = false;
// printf("[hsq] error in %d, out_ref_cpu_copy[%d]=%f, out_cpu_copy[%d]=%f\n", i, i, *(ref_data+i), i, *(cpu_data+i));
// break;
// }
// }
// if(dev_id == target_id) {
// if(correct) {
// printf("[hsq] index_select op test passed\n");
// }
// }

PADDLE_ENFORCE_EQ(r, xpu::Error_t::SUCCESS,
platform::errors::External(
"The index_select XPU OP return wrong value[%d %s]",
Expand Down Expand Up @@ -139,43 +94,9 @@ class IndexSelectGradXPUKernel : public framework::OpKernel<T> {
const T* out_grad_data = out_grad->data<T>();
T* x_grad_data = x_grad->mutable_data<T>(place);

// auto cpu_device_ctx = platform::DeviceContextPool::Instance().Get(phi::CPUPlace());
// framework::ExecutionContext cpu_execution_ctx(ctx.GetOp(), ctx.scope(), *cpu_device_ctx, ctx.Context());

// LoDTensor out_grad_cpu_copy;
// framework::TensorCopySync(*out_grad, platform::CPUPlace(), &out_grad_cpu_copy);
// LoDTensor index_cpu_copy;
// framework::TensorCopySync(*index, platform::CPUPlace(), &index_cpu_copy);
// LoDTensor x_grad_cpu_copy;
// framework::TensorCopySync(*x_grad, platform::CPUPlace(), &x_grad_cpu_copy);
// if (index_type == phi::DataType::INT32) {
// IndexSelectGradInner<phi::CPUContext, T, int>(cpu_execution_ctx, out_grad_cpu_copy, index_cpu_copy, &x_grad_cpu_copy, dim);
// } else if (index_type == phi::DataType::INT64) {
// IndexSelectGradInner<phi::CPUContext, T, int64_t>(
// cpu_execution_ctx, out_grad_cpu_copy, index_cpu_copy, &x_grad_cpu_copy, dim);
// }

int r = -1;
std::vector<int64_t> out_grad_shape = phi::vectorize<int64_t>(out_grad->dims());
std::vector<int64_t> x_grad_shape = phi::vectorize<int64_t>(x_grad->dims());

// static int target_id = std::getenv("HSQ_XPURT_TARGET_DEVICE")!=NULL ?
// std::stoi(std::string(std::getenv("HSQ_XPURT_TARGET_DEVICE"))) :
// 0;
// int dev_id = ctx.GetPlace().GetDeviceId();
// // if(dev_id == target_id) {
// // printf("[hsq] out_grad_shape:[");
// // for(int i = 0; i < (int)out_grad_shape.size(); i++) {
// // printf("%d, ", (int)out_grad_shape[i]);
// // }
// // printf("]\n");

// // printf("[hsq] x_grad_shape:[");
// // for(int i = 0; i < (int)x_grad_shape.size(); i++) {
// // printf("%d, ", (int)x_grad_shape[i]);
// // }
// // printf("]\n");
// // }
if (index_type == phi::DataType::INT64) {
const int64_t* index_data = index->data<int64_t>();
r = xpu::index_select_grad<T, int64_t>(xpu_context,
Expand All @@ -202,26 +123,6 @@ class IndexSelectGradXPUKernel : public framework::OpKernel<T> {
platform::errors::External(
"The index_select_grad XPU OP return wrong value[%d %s]",
r, XPUAPIErrorMsg[r]));

// LoDTensor x_grad_ref_cpu_copy;
// framework::TensorCopySync(*x_grad, platform::CPUPlace(), &x_grad_ref_cpu_copy);
// bool correct = true;
// float diff = 1e-5;
// for (int i = 0; i < x_grad_ref_cpu_copy.numel(); i++) {
// T* ref_data = x_grad_ref_cpu_copy.data<T>();
// T* cpu_data = x_grad_cpu_copy.data<T>();
// if(std::abs(*(ref_data + i) - *(cpu_data+i)) > diff) {
// correct = false;
// printf("[hsq] error in %d, out_ref_cpu_copy[%d]=%f, out_cpu_copy[%d]=%f\n", i, i, *(ref_data+i), i, *(cpu_data+i));
// break;
// }
// }

// if(dev_id == target_id) {
// if(correct) {
// printf("[hsq] index_select_grad op test passed\n");
// }
// }
}
};

Expand Down

0 comments on commit f4e322f

Please sign in to comment.