Skip to content

Add Test Suite for cTensor #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 7, 2025
Merged

Add Test Suite for cTensor #14

merged 20 commits into from
Jun 7, 2025

Conversation

Advaitgaur004
Copy link
Contributor

@Advaitgaur004 Advaitgaur004 commented Jun 5, 2025

Overview

This PR adds a comprehensive test framework to the cTensor project, implementing a test suite for tensor operators and setting up automated CI testing using GitHub Actions.

Changes

1. Test Suite Structure

  • Added tests/ directory with the main test runner (cten_tests.c)
  • Added  directory for operator-specific tests
  • Added tests/Operator/ directory for operator-specific tests
  • Added tests/Grad/ directory for gradient-related tests. (*These items are yet to be added).
  • Implemented CSV reporter for test results (tests/csv_reporter.c and tests/csv_reporter.h)

2. Operator Tests

Added tests for all operators in src/operator.c, including

  • Tensor_add
  • Tensor_matmul
  • Tensor_mean
  • Tensor_mul
  • Tensor_mulf
  • Tensor_sub
  • Tensor_sum

3. CI Integration

  • Added GitHub Actions workflow in .github/workflows/run-ctests.yml to build and run tests on Ubuntu, macOS, and Windows
  • Added test report analysis script in .github/check_all_results.py to parse CSV test reports
  • Added operator coverage checker in .github/check_operator_coverage.py to ensure all operators have tests
  • Added workflow in .github/workflows/check-operator-test-coverage.yml to enforce test coverage

4. Memory Management

  • Implemented proper memory pool handling in the test framework
  • Allocated dedicated pool IDs for test resources

Test Architecture

  • All tests compile into a single executable cten_tests
  • Tests use a simple CSV reporter to log results for CI analysis
  • Each operator has its own test file with multiple test cases
  • Test functions are forward-declared in cten_tests.c for centralized management

Guide to Test locally

  • Check cTensor\tests\README.md for proper guide

Notes

  • The PR enforces test coverage for all operators through CI checks
  • Fixed a bug in that was returning an incorrect shape Tensor_sum
  • Memory management is now properly handled in the test suite with dedicated pools

Advaitgaur004 and others added 20 commits May 25, 2025 19:18

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
- Minor Change is made test_pytorch_ref.c file so that it works with current ci, as string matching from the artificat take place and hence it should be exact same.

- check_all_results.py is changed to sorted output for consistent ordering

-run-tests.yml is also slightly changed to as in the Windows job, the path to the executable is incorrect, which is rectified

- LOCALLY TESTED
- Add, matmul, mean, mul, mulf, sub, sum
…r partipular operator under particular subtest category
@PrimedErwin PrimedErwin merged commit 381326f into pocketpy:test Jun 7, 2025
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.

None yet

2 participants