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 2021/01/29 14:34:03 UTC

[GitHub] [arrow] ritchie46 opened a new pull request #9361: Power kernel

ritchie46 opened a new pull request #9361:
URL: https://github.com/apache/arrow/pull/9361


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ritchie46 commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
ritchie46 commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r572044940



##########
File path: rust/arrow/src/compute/kernels/arithmetic.rs
##########
@@ -536,7 +555,29 @@ where
     #[cfg(simd)]
     return simd_signed_unary_math_op(array, |x| -x, |x| -x);
     #[cfg(not(simd))]
-    return signed_unary_math_op(array, |x| -x);
+    return Ok(unary(array, |x| -x));
+}
+
+/// Raise array to the power of a scalar.
+pub fn pow_scalar<T>(

Review comment:
       I renamed to `powf_scalar`. I still have a `scalar` suffix distinct with a (future) kernel that is a binary function (i.e. array to the power of array).




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] removed a comment on pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
github-actions[bot] removed a comment on pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#issuecomment-769854688


   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   Thanks for opening a pull request!
   
   Could you open an issue for this pull request on JIRA?
   https://issues.apache.org/jira/browse/ARROW
   
   Then could you also rename pull request title in the following format?
   
       ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}
   
   See also:
   
     * [Other pull requests](https://github.com/apache/arrow/pulls/)
     * [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ritchie46 commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
ritchie46 commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r568389045



##########
File path: rust/arrow/src/datatypes.rs
##########
@@ -920,6 +930,32 @@ make_signed_numeric_type!(Int64Type, i64x8);
 make_signed_numeric_type!(Float32Type, f32x16);
 make_signed_numeric_type!(Float64Type, f64x8);
 
+#[cfg(simd)]
+pub trait ArrowFloatNumericType: ArrowNumericType {
+    fn pow(base: Self::Simd, raise: Self::Simd) -> Self::Simd;

Review comment:
       For non-SIMD this would work indeed. However I could not proof my `SIMD` type had the `powf` method without this trait/ implementation. Or am I missing something?

##########
File path: rust/arrow/src/compute/kernels/arithmetic.rs
##########
@@ -35,20 +35,17 @@ use crate::datatypes;
 use crate::datatypes::ArrowNumericType;
 use crate::error::{ArrowError, Result};
 use crate::{array::*, util::bit_util};
+use num::traits::Pow;
 #[cfg(simd)]
 use std::borrow::BorrowMut;
 #[cfg(simd)]
 use std::slice::{ChunksExact, ChunksExactMut};
 
 /// Helper function to perform math lambda function on values from single array of signed numeric
 /// type. If value is null then the output value is also null, so `-null` is `null`.
-pub fn signed_unary_math_op<T, F>(
-    array: &PrimitiveArray<T>,
-    op: F,
-) -> Result<PrimitiveArray<T>>
+pub fn unary_math_op<T, F>(array: &PrimitiveArray<T>, op: F) -> Result<PrimitiveArray<T>>

Review comment:
       Right.. Then there is some duplication. What do you propose? Use the `crate::array::compute::kernels::arity::unary` for the logic in this model as wel? To me that seems more DRY.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #9361: Power kernel

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#issuecomment-769844288


   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   Thanks for opening a pull request!
   
   Could you open an issue for this pull request on JIRA?
   https://issues.apache.org/jira/browse/ARROW
   
   Then could you also rename pull request title in the following format?
   
       ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}
   
   See also:
   
     * [Other pull requests](https://github.com/apache/arrow/pulls/)
     * [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ritchie46 commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
ritchie46 commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r568389880



##########
File path: rust/arrow/src/compute/kernels/arithmetic.rs
##########
@@ -35,20 +35,17 @@ use crate::datatypes;
 use crate::datatypes::ArrowNumericType;
 use crate::error::{ArrowError, Result};
 use crate::{array::*, util::bit_util};
+use num::traits::Pow;
 #[cfg(simd)]
 use std::borrow::BorrowMut;
 #[cfg(simd)]
 use std::slice::{ChunksExact, ChunksExactMut};
 
 /// Helper function to perform math lambda function on values from single array of signed numeric
 /// type. If value is null then the output value is also null, so `-null` is `null`.
-pub fn signed_unary_math_op<T, F>(
-    array: &PrimitiveArray<T>,
-    op: F,
-) -> Result<PrimitiveArray<T>>
+pub fn unary_math_op<T, F>(array: &PrimitiveArray<T>, op: F) -> Result<PrimitiveArray<T>>

Review comment:
       Right.. Then there is some duplication. What do you propose? Use the `crate::array::compute::kernels::arity::unary` for the logic in this model as wel? To me that seems more DRY.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nevi-me closed pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
nevi-me closed pull request #9361:
URL: https://github.com/apache/arrow/pull/9361


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nevi-me commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r571736477



##########
File path: rust/arrow/src/compute/kernels/arithmetic.rs
##########
@@ -536,7 +555,29 @@ where
     #[cfg(simd)]
     return simd_signed_unary_math_op(array, |x| -x, |x| -x);
     #[cfg(not(simd))]
-    return signed_unary_math_op(array, |x| -x);
+    return Ok(unary(array, |x| -x));
+}
+
+/// Raise array to the power of a scalar.
+pub fn pow_scalar<T>(

Review comment:
       Given that this function is [powf](https://doc.rust-lang.org/stable/std/primitive.f64.html#method.powf), WDYT about renaming it as such? We're going to also have `pow` for the integer types, `powi` to raise floats to an integer power. So we could preempt the possible rename.
   
   I'll remove the `powf` in #9313 because this one has a SIMD implementation.
   
   An additional benefit of splitting `powf` and `powi` is that `powi` is faster.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ritchie46 commented on pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
ritchie46 commented on pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#issuecomment-775715875


   Rebased! :+1: 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#issuecomment-769854688


   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   Thanks for opening a pull request!
   
   Could you open an issue for this pull request on JIRA?
   https://issues.apache.org/jira/browse/ARROW
   
   Then could you also rename pull request title in the following format?
   
       ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}
   
   See also:
   
     * [Other pull requests](https://github.com/apache/arrow/pulls/)
     * [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nevi-me commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r571736477



##########
File path: rust/arrow/src/compute/kernels/arithmetic.rs
##########
@@ -536,7 +555,29 @@ where
     #[cfg(simd)]
     return simd_signed_unary_math_op(array, |x| -x, |x| -x);
     #[cfg(not(simd))]
-    return signed_unary_math_op(array, |x| -x);
+    return Ok(unary(array, |x| -x));
+}
+
+/// Raise array to the power of a scalar.
+pub fn pow_scalar<T>(

Review comment:
       Given that this function is [powf](https://doc.rust-lang.org/stable/std/primitive.f64.html#method.powf), WDYT about renaming it as such? We're going to also have `pow` for the integer types, `powi` to raise floats to an integer power. So we could preempt the possible rename.
   
   I'll remove the `powf` in #9313 because this one has a SIMD implementation.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] removed a comment on pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
github-actions[bot] removed a comment on pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#issuecomment-769844288


   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   Thanks for opening a pull request!
   
   Could you open an issue for this pull request on JIRA?
   https://issues.apache.org/jira/browse/ARROW
   
   Then could you also rename pull request title in the following format?
   
       ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}
   
   See also:
   
     * [Other pull requests](https://github.com/apache/arrow/pulls/)
     * [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nevi-me commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r571733973



##########
File path: rust/arrow/src/datatypes.rs
##########
@@ -920,6 +930,32 @@ make_signed_numeric_type!(Int64Type, i64x8);
 make_signed_numeric_type!(Float32Type, f32x16);
 make_signed_numeric_type!(Float64Type, f64x8);
 
+#[cfg(simd)]
+pub trait ArrowFloatNumericType: ArrowNumericType {
+    fn pow(base: Self::Simd, raise: Self::Simd) -> Self::Simd;

Review comment:
       You're right, if it's not possible to only add the trait for SIMD types, then it's a reasonable change to make.
   The downside's that the trait's going to grow when we add more compute kernels (with SIMD support).




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ritchie46 commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
ritchie46 commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r569207411



##########
File path: rust/arrow/src/compute/kernels/arithmetic.rs
##########
@@ -35,20 +35,17 @@ use crate::datatypes;
 use crate::datatypes::ArrowNumericType;
 use crate::error::{ArrowError, Result};
 use crate::{array::*, util::bit_util};
+use num::traits::Pow;
 #[cfg(simd)]
 use std::borrow::BorrowMut;
 #[cfg(simd)]
 use std::slice::{ChunksExact, ChunksExactMut};
 
 /// Helper function to perform math lambda function on values from single array of signed numeric
 /// type. If value is null then the output value is also null, so `-null` is `null`.
-pub fn signed_unary_math_op<T, F>(
-    array: &PrimitiveArray<T>,
-    op: F,
-) -> Result<PrimitiveArray<T>>
+pub fn unary_math_op<T, F>(array: &PrimitiveArray<T>, op: F) -> Result<PrimitiveArray<T>>

Review comment:
       @nevi-me I removed the helper function and used the `arity::unary::kernel`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ritchie46 commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
ritchie46 commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r568389045



##########
File path: rust/arrow/src/datatypes.rs
##########
@@ -920,6 +930,32 @@ make_signed_numeric_type!(Int64Type, i64x8);
 make_signed_numeric_type!(Float32Type, f32x16);
 make_signed_numeric_type!(Float64Type, f64x8);
 
+#[cfg(simd)]
+pub trait ArrowFloatNumericType: ArrowNumericType {
+    fn pow(base: Self::Simd, raise: Self::Simd) -> Self::Simd;

Review comment:
       For non-SIMD this would work indeed. However I could not proof my `SIMD` type had the `powf` method without this trait/ implementation. Or am I missing something?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#issuecomment-770067665


   https://issues.apache.org/jira/browse/ARROW-11428


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nevi-me commented on a change in pull request #9361: ARROW-11428: [Rust] Add power_scalar kernel

Posted by GitBox <gi...@apache.org>.
nevi-me commented on a change in pull request #9361:
URL: https://github.com/apache/arrow/pull/9361#discussion_r568174115



##########
File path: rust/arrow/src/compute/kernels/arithmetic.rs
##########
@@ -35,20 +35,17 @@ use crate::datatypes;
 use crate::datatypes::ArrowNumericType;
 use crate::error::{ArrowError, Result};
 use crate::{array::*, util::bit_util};
+use num::traits::Pow;
 #[cfg(simd)]
 use std::borrow::BorrowMut;
 #[cfg(simd)]
 use std::slice::{ChunksExact, ChunksExactMut};
 
 /// Helper function to perform math lambda function on values from single array of signed numeric
 /// type. If value is null then the output value is also null, so `-null` is `null`.
-pub fn signed_unary_math_op<T, F>(
-    array: &PrimitiveArray<T>,
-    op: F,
-) -> Result<PrimitiveArray<T>>
+pub fn unary_math_op<T, F>(array: &PrimitiveArray<T>, op: F) -> Result<PrimitiveArray<T>>

Review comment:
       This simplification makes this identical to `crate::array::compute::kernels::arity::unary`, which was recently added.

##########
File path: rust/arrow/src/datatypes.rs
##########
@@ -920,6 +930,32 @@ make_signed_numeric_type!(Int64Type, i64x8);
 make_signed_numeric_type!(Float32Type, f32x16);
 make_signed_numeric_type!(Float64Type, f64x8);
 
+#[cfg(simd)]
+pub trait ArrowFloatNumericType: ArrowNumericType {
+    fn pow(base: Self::Simd, raise: Self::Simd) -> Self::Simd;

Review comment:
       We could avoid creating this trait by using `num::Float` as a constraint for floaing types. See #9313, though I wasn't doing it for a SIMD implementation




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org