You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/03 05:10:43 UTC
[GitHub] [arrow-rs] viirya opened a new pull request, #2640: Use `downcast_primitive_array` in arithmetic kernels
viirya opened a new pull request, #2640:
URL: https://github.com/apache/arrow-rs/pull/2640
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #2639.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962200424
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
Ah, good point. But I guess the suggested one will also panic on `let right = as_primitive_array(right);` if `right` is not same type?
Let me do a test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962205557
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
Oh oh right. 😄
Good news is it works.
But as `Float16Type` doesn't implement `ArrowNumericType`, I need to remove `Float16Type` pattern from `downcast_primitive_array!` to make it work.
For `simd` feature, seems f16 related APIs are not available so it appears not easy to let `Float16Type` implement `ArrowNumericType`.
Currently I leave single argument `downcast_primitive_array!` untouched and stick with two argument one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962196627
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
This has an implicit assumption that $values1 and $values2 have the same type, not only is this potentially surprising as an API, but I think it changes the behaviour of the kernels which will now panic where previously they would work?
Adding `$values2.data_type()` to the match might work, but it still feels a bit confusing? :thinking:
I wonder if we could instead do something like this
```
downcast_primitive_array!(
left => {
let right = as_primitive_array(right);
multiply(left, right).map(|a| Arc::new(a) as ArrayRef)
}
_ => Err(ArrowError::CastError(format!(
"Unsupported data type {}, {}",
left.data_type(), right.data_type()
)))
)
```
And rely on the fact the generic kernels constrain them to be the same type. I don't know, perhaps this is hack...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962196627
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
This has an implicit assumption that $values1 and $values2 have the same type, not only is this potentially surprising as an API, but I think it changes the behaviour of the kernels which will now panic where previously they would return an error?
Adding `$values2.data_type()` to the match might work, but this still feels a bit confusing as an API? :thinking:
I wonder if we could instead do something like this
```
downcast_primitive_array!(
left => {
let right = as_primitive_array(right);
multiply(left, right).map(|a| Arc::new(a) as ArrayRef)
}
_ => Err(ArrowError::CastError(format!(
"Unsupported data type {}, {}",
left.data_type(), right.data_type()
)))
)
```
And rely on the fact the generic kernels constrain them to be the same type. I don't know, perhaps this is hack...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#issuecomment-1236050731
Did a benchmark run and no obvious difference found.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962205557
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
Oh oh right. 😄
Good news is it works.
But as `Float16Type` doesn't implement `ArrowNumericType`, I need to remove `Float16Type` pattern from `downcast_primitive_array!` to make it work.
For `simd` feature, seems f16 related APIs are not available so it appears not easy to let `Float16Type` implement `ArrowNumericType`.
Currently I leave single argument `downcast_primitive_array!` untouched and stick with two argument one and make it constrain the two arguments must be same type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold merged pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
tustvold merged PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962196627
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
This has an implicit assumption that $values1 and $values2 have the same type, not only is this potentially surprising as an API, but I think it changes the behaviour of the kernels which will now panic where previously they would return an error?
Adding `$values2.data_type()` to the match might work, but it still feels a bit confusing? :thinking:
I wonder if we could instead do something like this
```
downcast_primitive_array!(
left => {
let right = as_primitive_array(right);
multiply(left, right).map(|a| Arc::new(a) as ArrayRef)
}
_ => Err(ArrowError::CastError(format!(
"Unsupported data type {}, {}",
left.data_type(), right.data_type()
)))
)
```
And rely on the fact the generic kernels constrain them to be the same type. I don't know, perhaps this is hack...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#issuecomment-1236190826
Btw very cool to see these being used already :heart:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962203863
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
Hmm, `math_op` doesn't constrain two sides of op should be same type. So
```rust
downcast_primitive_array!(
left => {
let right = as_primitive_array(right);
math_op(left, right, |a, b| a + b).map(|a| Arc::new(a) as ArrayRef)
}
_ => Err(ArrowError::CastError(format!(
"Unsupported data type {}, {}",
left.data_type(), right.data_type()
)))
)
```
will not constrain the right side type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#discussion_r962204473
##########
arrow/src/array/cast.rs:
##########
@@ -225,6 +225,255 @@ macro_rules! downcast_primitive_array {
$($p => $fallback,)*
}
};
+
+ (($values1:ident, $values2:ident) => $e:block $($p:pat => $fallback:expr $(,)*)*) => {
Review Comment:
> suggested one will
Yeah, you will still need to check the type, it is what it is
> doesn't constrain the type
That's why i suggested using the generic kernel not math_op directly 😃
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] ursabot commented on pull request #2640: Use `downcast_primitive_array` in arithmetic kernels
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2640:
URL: https://github.com/apache/arrow-rs/pull/2640#issuecomment-1236859928
Benchmark runs are scheduled for baseline = b46fc9287da22534f0599651597fc13cb675ddff and contender = 30ab9bba5c133bb32be6cde307d5111c0088bce1. 30ab9bba5c133bb32be6cde307d5111c0088bce1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/890269c881944e37a48c50da51baa3df...3c5ec4c16e81463aa584874564fa436a/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/1b79dc39b2f2479f9ba812101e96a013...b6d9eb01a2b44ba9b05a99750bd0a503/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/f0770570619445dbb3874f172e2c6b06...7d528af7573f40a3b543e3d52076945c/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/d6f2047ae319482b9aed491de8f220ef...3311d93351724d89be587e001180d20a/)
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org