GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — New data generation functions and Neg trait implementation by 9prady9 · Pull Request #94 · arrayfire/arrayfire-rust Conversationfunction to create an array with same shape and type as input array filled with a constant
This was referenced
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
jramapuram
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good. Just the one query.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a benefit to this vs the following? af::mul(&-1.0, &self);
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both are doing same number of operations (create a constant array and then do arithmetic operation of two arrays) under the hood except that the intrinsic operation is subtraction in the trait implementation where as the other version is doing multiplication. I think they would perform about the same - compiler may even optimise it for this particular cases (Multiplication by -1 and Subtraction from 0).
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice addition
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
jramapuram
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see why you made these separate from the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jramapuram How can we do this using enum ?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking of something like this: https://is.gd/taX9ac
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to remove all the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
| /// # Return Values | ||
| /// | ||
| /// Array filled with `value` and `dims` shape. | ||
| pub fn create_constant_u64(value: u64, dims: Dim4) -> Array { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Same comment w.r.t. create_
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /// # Return Values | ||
| /// Array | ||
| #[allow(unused_mut)] | ||
| pub fn create_range(dims: Dim4, seq_dim: i32, dtype: DType) -> Array { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Same comment w.r.t. create_
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /// | ||
| /// Identity matrix | ||
| #[allow(unused_mut)] | ||
| pub fn create_identity(dims: Dim4, dtype: DType) -> Array { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Same comment w.r.t. create_
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /// | ||
| /// Array | ||
| #[allow(unused_mut)] | ||
| pub fn create_iota(dims: Dim4, tdims: Dim4, dtype: DType) -> Array { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Same comment w.r.t. create_
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I found the need for constant a while ago. But since I don't really need use af; use conv::{ConvUtil, Saturate}; /// Helper to return a constant value based on type pub fn constant(dims: Dim4, aftype: DType, val: f32) -> Array { match aftype { DType::F32 => af::constant(val, dims), DType::F64 => af::constant(val.approx_as::<f64>().unwrap(), dims), DType::C32 => af::constant(Complex::new(val, 0f32) , dims), DType::C64 => af::constant(Complex::new(val.approx_as::<f64>().unwrap(), 0f64) , dims), DType::B8 => { if val > 0f32 { af::constant(true, dims) }else{ af::constant(false, dims) } }, DType::S32 => af::constant(val.approx_as::<i32>().saturate().unwrap(), dims), DType::U32 => af::constant(val.approx_as::<u32>().saturate().unwrap(), dims), DType::U8 => af::constant(val.approx_as::<u8>().saturate().unwrap(), dims), DType::S64 => af::constant(val.approx_as::<i64>().saturate().unwrap(), dims), DType::U64 => af::constant(val.approx_as::<u64>().saturate().unwrap(), dims), DType::S16 => af::constant(val.approx_as::<i16>().saturate().unwrap(), dims), DType::U16 => af::constant(val.approx_as::<u16>().saturate().unwrap(), dims), } } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jramapuram I don't like the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@pavanky @jramapuram Feedback pls, i want to release 3.4.1 of this wrapper this week if possible. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
why won't the function shown here work: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
That version is sacrificing accuracy of I don't think we can do that as a library. Edited: Added to that, we can't have another function with same name as |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@9prady9 accept |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I didn't check C++ API, but C API of arrayfire has different functions for Edited:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@9prady9 I wasn't talking about having multiple functions, but about the name (specifically the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, we can't have same names. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
For him it is working because he had them in different namespace. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry for the delay. Infrequent internet over the winter break. Will review in 2 days. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@arrayfire/rust-devel Awaiting feedback. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Added a simple way to use Enums in comments. Another possible (but have not tested myself) way is to use generics: http://stackoverflow.com/questions/26810793/how-can-i-create-an-is-prime-function-that-is-generic-over-various-integer-types See solution in that answer as well as comment in accepted answer. Not sure if the generics are robust enough to accept all numeric types yet though. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* constant_t * range_t * range_t * iota_t
d202256 to
10a20d1
Compare
|
@jramapuram please check now. Using your suggestion, i have consolidated all the separate create_constant_* functions into a single function @pavanky please check now. I have renamed all create_* fns to have |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
looks good 👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks great! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.