Skip to content

Conversation

@ravituringworks
Copy link

Summary

  • Add ArcSin, ArcCos, ArcTan, ArcSinh, ArcCosh, ArcTanh trait implementations for Line<P>
  • Also adds missing Tan, Sinh, Cosh implementations for completeness
  • Enables native GPU acceleration for inverse trigonometric operations on vectorized types

Motivation

The Line<P> type was missing trait implementations for inverse trigonometric and hyperbolic functions, even though:

  1. The traits are already defined in unary.rs
  2. The IR layer supports these operations (Arithmetic::ArcSin, etc.)
  3. All backends (CUDA, SPIR-V, WGSL) already handle code generation for these operations

This change simply exposes the existing functionality to Line<P>, following the same pattern used for Sin, Cos, and Tanh.

Changes

File: crates/cubecl-core/src/frontend/container/line/ops.rs

  • Updated imports to include the missing traits
  • Added blank trait implementations that delegate to the underlying primitive type P

Test plan

  • Existing unary tests pass (includes test_asin, test_acos, test_atan, test_asinh, test_acosh, test_atanh with vectorization levels 2 and 4)
  • cargo check -p cubecl-core passes
  • cargo test -p cubecl-wgpu -- unary passes (27 tests)

🤖 Generated with Claude Code

Implement ArcSin, ArcCos, ArcTan, ArcSinh, ArcCosh, ArcTanh traits for
Line<P> to enable native GPU acceleration for these operations. Also
adds missing Tan, Sinh, Cosh implementations for completeness.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 2, 2026 20:16
Copy link

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 missing inverse trigonometric and hyperbolic function trait implementations for the Line<P> type, enabling native GPU acceleration for these operations on vectorized types. The changes expose existing functionality that was already implemented in the IR layer and backend code generation.

Key Changes

  • Added ArcSin, ArcCos, ArcTan, ArcSinh, ArcCosh, and ArcTanh trait implementations for Line<P>
  • Added missing Tan, Sinh, and Cosh implementations for completeness
  • Updated imports to include all new traits in alphabetical order

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

Comment on lines +258 to +259
impl<P: CubePrimitive + ArcSin> ArcSin for Line<P> {}
impl<P: CubePrimitive + ArcCos> ArcCos for Line<P> {}
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The ordering of inverse trigonometric trait implementations is inconsistent with the reference implementation in crates/cubecl-core/src/frontend/element/float/typemap.rs. In that file, the order is ArcCos, ArcSin, ArcTan (lines 254-256), but here it's ArcSin, ArcCos, ArcTan. For consistency and maintainability, these should follow the same order as the reference implementation.

Suggested change
impl<P: CubePrimitive + ArcSin> ArcSin for Line<P> {}
impl<P: CubePrimitive + ArcCos> ArcCos for Line<P> {}
impl<P: CubePrimitive + ArcCos> ArcCos for Line<P> {}
impl<P: CubePrimitive + ArcSin> ArcSin for Line<P> {}

Copilot uses AI. Check for mistakes.
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.

1 participant