Skip to content
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

Added doc-comments to tensor.rs #12

Merged
merged 3 commits into from
Mar 31, 2024

Conversation

nestordemeure
Copy link
Contributor

Following the discussion in issue11, here is a PR adding doc comments to tensor.rs. This is a first test in introducing AI-generated comments to document the library faster, making it easier to pick up by new users.

Here is a preview of what it looks like in conditions (cargo doc --open --no-deps --all-features):

image
image

This is a test to think about the viability of this approach. Do feel free to comment and criticize (things can definitely be streamlined by hand, this PR had no manual tweak of the comments so far)!

For archival purposes, here is the prompt used to generate the comments (with GPT-4):

You will be given code from `nox`, a Rust implementation of JAX. Your goal is to doc-comment the code:
* adding a top-level doc comment (describing the current file's function),
* doc comment the functions (helping users understand the arguments and outputs of the function),
* doc comment types and traits.

Your output should be only the doc comments and headers, no need to include the rest of the code.

Also, keep your comments short and useful. No point in stating the obvious or writing a long sentence where a short one would do. Those comments should be there to help a new user understand how to use the library from a quick look.

Copy link
Contributor

@akhilles akhilles left a comment

Choose a reason for hiding this comment

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

This is pretty good! The top level comments are all fine. Some of the comments on associated types and trait functions seem a bit unnecessary. Especially for Out, Output. @sphw, could you take a look as well?

pub trait MapDim<D> {
/// The item associated with the dimension mapping.
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably don't need these inner comments.

pub trait DimConcat<A, B> {
/// The resulting dimension type after concatenation.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is implied.

pub trait TensorIndex<T, D: TensorDim> {
/// The output type resulting from the indexing operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is implied.

@akhilles
Copy link
Contributor

The commit message has a typo btw

@nestordemeure
Copy link
Contributor Author

Thanks, I have fixed the commit text and removed inner comments.

Copy link
Contributor

@akhilles akhilles left a comment

Choose a reason for hiding this comment

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

Just have a nitpick on the Tensor comment, but ok to merge once that's fixed.

@@ -10,6 +11,8 @@ use std::{
};
use xla::{ArrayElement, ElementType, NativeType};

/// Represents a tensor with a specific type `T`, dimensionality `D`, and parameterization `P`.
Copy link
Contributor

Choose a reason for hiding this comment

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

"underlying representation P" is a bit more accurate.

@@ -10,6 +11,8 @@ use std::{
};
use xla::{ArrayElement, ElementType, NativeType};

/// Represents a tensor with a specific type `T`, dimensionality `D`, and parameterization `P`.
/// `P` dictates the underlying representation and operations available on the tensor.
Copy link
Contributor

Choose a reason for hiding this comment

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

"operations available on the tensor" is not quite accurate. Would just drop this sentence, and change the previous sentence to include the "underlying representation" part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@akhilles akhilles merged commit 5ef3175 into elodin-sys:main Mar 31, 2024
akhilles pushed a commit that referenced this pull request Mar 31, 2024
akhilles pushed a commit that referenced this pull request Apr 18, 2024
@nestordemeure nestordemeure deleted the documentation branch April 30, 2024 21:39
@nestordemeure nestordemeure restored the documentation branch April 30, 2024 21:39
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