Skip to content

compile tests when passing PADDLE_WITH_CUSTOM_KERNEL macro#60

Open
youge325 wants to merge 18 commits intoPFCCLab:masterfrom
youge325:cResetHolder
Open

compile tests when passing PADDLE_WITH_CUSTOM_KERNEL macro#60
youge325 wants to merge 18 commits intoPFCCLab:masterfrom
youge325:cResetHolder

Conversation

@youge325
Copy link
Copy Markdown
Contributor

@youge325 youge325 commented Apr 29, 2026

在cpp层复现 MaybeResetHolder 的问题

最后一次修改,覆盖率报告如下:
image

Copilot AI review requested due to automatic review settings April 29, 2026 08:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a CMake switch to compile Paddle-side gtests with PADDLE_WITH_CUSTOM_KERNEL (without affecting Torch-side builds), and moves the previously external resize repro into the C++ gtest suite to reproduce the MaybeResetHolder-related behavior.

Changes:

  • Add ENABLE_PADDLE_CUSTOM_KERNEL_COMPAT_TESTS to optionally compile Paddle tests with PADDLE_WITH_CUSTOM_KERNEL.
  • Add a new TensorTest case to validate storage nbytes() growth behavior after resize_().
  • Remove the standalone resize_repro Python/C++ extension repro scaffolding.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
CMakeLists.txt Adds an opt-in CMake option that appends PADDLE_WITH_CUSTOM_KERNEL only to Paddle test targets.
test/ATen/core/TensorTest.cpp Adds ResizeGrowStorageNbytes gtest and includes <cstdint> for int32_t.
README.md Documents how to build a separate directory enabling the Paddle custom-kernel compat define.
.gitignore Removes Python-related ignore patterns.
resize_repro/setup.py Deleted (previous standalone extension build script).
resize_repro/run_test.py Deleted (previous standalone runner).
resize_repro/resize_repro.cpp Deleted (previous standalone C++ repro extension).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +750 to +759
const size_t before_bytes = grow.storage().nbytes();

grow.resize_({4});

const size_t after_bytes = grow.storage().nbytes();
const size_t expected_bytes = 4 * sizeof(int32_t);
const bool shape_ok = grow.numel() == 4;
const bool storage_ok = after_bytes >= expected_bytes;

file << std::to_string(before_bytes >= 2 * sizeof(int32_t) ? 1 : 0) << " ";
Comment thread CMakeLists.txt Outdated
Comment on lines +214 to +219
if(ENABLE_PADDLE_CUSTOM_KERNEL_COMPAT_TESTS)
message(
STATUS
"Paddle compat tests enabled with PADDLE_WITH_CUSTOM_KERNEL definition.")
list(APPEND _paddle_cuda_defs "PADDLE_WITH_CUSTOM_KERNEL")
endif()
youge325 and others added 17 commits April 30, 2026 12:22
…btorch

In CPU-only libtorch builds, c10/cuda/CUDAStream.h includes
cuda_runtime_api.h which is unavailable. Wrap CUDA-specific includes,
has_cuda_runtime() helper, and CUDA-only test cases with #ifdef USE_CUDA.

CMakeLists.txt now passes USE_CUDA to torch test targets only when
TORCH_HAS_CUDA_SUPPORT is ON.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants