Skip to content

[BugFix] Add float4 definitions to cpp/common.h for CPU backend#1902

Closed
ShaobinChen-AH wants to merge 1 commit intotile-ai:mainfrom
ShaobinChen-AH:fix/cpu-float4-definition
Closed

[BugFix] Add float4 definitions to cpp/common.h for CPU backend#1902
ShaobinChen-AH wants to merge 1 commit intotile-ai:mainfrom
ShaobinChen-AH:fix/cpu-float4-definition

Conversation

@ShaobinChen-AH
Copy link
Contributor

@ShaobinChen-AH ShaobinChen-AH commented Mar 5, 2026

Problem

When compiling CPU kernels that use T.copy, the generated code references float4 type which is not defined, causing compilation errors:

Root Cause

The CPU backend uses tl_templates/cpp/common.h which lacked float4 definitions. CUDA backend doesn't need this because float4 is built into CUDA SDK.

Fix

  • Add float4 struct definition to src/tl_templates/cpp/common.h
  • Add C++ constructors:
    • Default constructor
    • Single float constructor (for broadcast operations)
    • Four floats constructor
  • Add make_float4 helper function

Testing

pytest testing/python/cpu/test_tilelang_cpu_gemm.py::test_matmul_with_copy_cython -v
# PASSED


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Added vector type support in the backend for enhanced computational operations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d078d669-e948-4a14-bd06-c00ccc57f495

📥 Commits

Reviewing files that changed from the base of the PR and between 00267e4 and 289ef29.

📒 Files selected for processing (1)
  • src/tl_templates/cpp/common.h

📝 Walkthrough

Walkthrough

Introduces a cross-language float4 vector type with C++ constructors (default, scalar, component-wise) and a C typedef, alongside a make_float4 factory helper function. Replaces a previous "Not Implemented" placeholder in the common header.

Changes

Cohort / File(s) Summary
Vector Type Definition
src/tl_templates/cpp/common.h
Added struct float4 with three constructors (default, single-value, component-wise), C typedef variant, and make_float4() factory function for creating instances across C and C++ code paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • LJC00118
  • LeiWang1999
  • SiriusNEO

Poem

🐰 A four-float friend now hops through code,
With constructors bright on each abode,
Both C and C++ shall play along,
With make_float4's helper song!
Let vectors dance where CPUs go,
Four components, all aglow! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding float4 definitions to cpp/common.h for the CPU backend to fix compilation errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run pre-commit run --all-files in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀

@SiriusNEO
Copy link
Collaborator

Repeated: #1901

@SiriusNEO SiriusNEO closed this Mar 5, 2026
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