Skip to content

Conversation

@shashaka
Copy link
Collaborator

@shashaka shashaka commented Dec 1, 2025

Adds keras.ops.vander, which constructs a Vandermonde matrix from a 1-D input tensor.
Supported across NumPy, TensorFlow, PyTorch, and JAX backends.
Not supported on OpenVINO.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @shashaka, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the vander function to the keras.ops module, enabling the creation of Vandermonde matrices within the Keras ecosystem. This new operation is designed for multi-backend compatibility, with specific implementations for NumPy, TensorFlow, PyTorch, and JAX, ensuring robust and consistent numerical behavior. It also includes necessary input validation and proper handling for symbolic tensors, while explicitly noting its current unavailability for the OpenVINO backend.

Highlights

  • New vander function: Introduced keras.ops.vander to construct Vandermonde matrices from 1-D input tensors.
  • Multi-backend support: Implemented for NumPy, TensorFlow, PyTorch, and JAX backends, ensuring consistent behavior across frameworks.
  • OpenVINO exclusion: Explicitly marked vander as not supported for the OpenVINO backend, with a NotImplementedError.
  • Input validation: Added comprehensive validation for input tensor dimensions, N (number of columns), and increasing parameter.
  • Symbolic tensor handling: Included a Vander operation class to correctly handle symbolic tensors and infer output shapes.
  • Unit tests: Comprehensive tests were added to verify the correctness, shape inference, and dtype handling of the vander function across different scenarios.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the keras.ops.vander function, providing a consistent API for creating Vandermonde matrices across NumPy, JAX, PyTorch, and TensorFlow backends. The implementation is well-structured, with backend-specific logic and a unified public-facing operation.

I've identified a couple of areas for improvement. There are potential precision loss issues in the NumPy and TensorFlow backend implementations when handling float64 inputs, for which I've provided suggestions. Additionally, I've noted that the input validation logic is duplicated across all backends and could be centralized in the main vander op function to improve maintainability.

Overall, this is a solid contribution. The tests are comprehensive, covering shapes, correctness, and dtypes.

@codecov-commenter
Copy link

codecov-commenter commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 79.31034% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.57%. Comparing base (f2c00fe) to head (ac0728d).

Files with missing lines Patch % Lines
keras/src/ops/numpy.py 64.28% 5 Missing and 5 partials ⚠️
keras/api/_tf_keras/keras/ops/__init__.py 0.00% 1 Missing ⚠️
keras/api/_tf_keras/keras/ops/numpy/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21882      +/-   ##
==========================================
- Coverage   82.57%   82.57%   -0.01%     
==========================================
  Files         577      577              
  Lines       59599    59657      +58     
  Branches     9351     9360       +9     
==========================================
+ Hits        49213    49259      +46     
- Misses       7978     7985       +7     
- Partials     2408     2413       +5     
Flag Coverage Δ
keras 82.38% <79.31%> (-0.01%) ⬇️
keras-jax 62.86% <44.82%> (-0.02%) ⬇️
keras-numpy 57.51% <50.00%> (-0.01%) ⬇️
keras-openvino 34.33% <32.75%> (-0.01%) ⬇️
keras-tensorflow 64.40% <60.34%> (-0.01%) ⬇️
keras-torch 63.56% <46.55%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants