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

[Feature Request] DType info methods #51

Closed
lsh opened this issue May 9, 2023 · 10 comments
Closed

[Feature Request] DType info methods #51

lsh opened this issue May 9, 2023 · 10 comments
Labels
enhancement New feature or request mojo-stdlib Tag for issues related to standard library

Comments

@lsh
Copy link
Contributor

lsh commented May 9, 2023

A few DType methods would be nice such as:

  • min_number[T: DType]() -> Int
  • max_number[T: DType]() -> Int
  • bits[T: DType]() -> Int
  • infinity[T: DType]() -> SIMD[T, 1] for floating point types
  • nan[T: DType]() -> SIMD[T, 1] for floating point types
@lsh lsh added enhancement New feature or request mojo-external labels May 9, 2023
@jayant-01
Copy link

hello, @lsh what we have to do here?

@lsh
Copy link
Contributor Author

lsh commented May 9, 2023

@jayant-01 What I'm asking for amounts to just defining a few constants, kind of like the C numeric limits or the associated constants on Rust types. Ideally it would also work for Int and FloatLiteral. One point to hash out is the actual API, since I think something like min_number[T: DType]() -> SIMD[T, 1] would be nice, which would in that case return the lowest possible value for the given DType.

@jayant-01
Copy link

ook @lsh i understand it,

so basically we have a creat like a function which will return the lowest value in a list or any other dataset

@jayant-01
Copy link

Am i right??

@jayant-01
Copy link

hello @lsh did i get it wrong please rectify ?

@lsh
Copy link
Contributor Author

lsh commented May 9, 2023

@jayant-01 that's not exactly right. I'm asking for a function that will return the lowest possible value for a type, and the highest possible value for that type. These wouldn't change based on the dataset or input, except for something like Int, which is hardware defined if I understand correctly.

@lattner
Copy link
Collaborator

lattner commented May 9, 2023

I think the request here is pretty straight-forward and logical. @abduld can you route this appropriately?

@jayant-01
Copy link

@lsh currently I don't have the access to Mojo playground so first let me have the permission then I can work on this.

Is that will be okay?

@abduld
Copy link
Contributor

abduld commented May 22, 2023

This makes perfect sense. One thing is that there are function like inf, nan, and neg_inf that are in the stdlib. Thanks for the suggestion to complete adding the numeric traits functions

@abduld abduld self-assigned this Jun 6, 2023
@goldiegadde goldiegadde added the mojo-stdlib Tag for issues related to standard library label Jun 20, 2023
@Mogball Mogball closed this as completed Jul 20, 2023
@Mogball
Copy link
Collaborator

Mogball commented Jul 20, 2023

Fixed in latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mojo-stdlib Tag for issues related to standard library
Projects
None yet
Development

No branches or pull requests

6 participants