--
You received this message because you are subscribed to the Google Groups "Swift for TensorFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swift+un...@tensorflow.org.
On Apr 18, 2019, at 9:14 AM, Anthony Platanios <e.a.pl...@gmail.com> wrote:Thanks Chris!That's an interesting point! Does that have any effect in how the compiler would treat say `.&&`, or is it mainly a semantics issue? Because there are two parts to the interpretation of `&&`: (i) it performs a logical and operation, and (ii) it is short-circuiting. Given that it could not be short-circuiting for tensors when performed element-wise, using `.&&`, it could potentially still be used to perform a logical and operation. The main disadvantage to this would potentially be the expectation from users that this is short circuiting, but I don't really know how much of an issue this would be for `.&&` (assuming the convention of `.XX` being element-wise operations).
static func .&(lhs: SIMDMask, rhs: SIMDMask) -> SIMDMask static func .^(lhs: SIMDMask, rhs: SIMDMask) -> SIMDMask static func .|(lhs: SIMDMask, rhs: SIMDMask) -> SIMDMask
My concern is that the current `elementsLogicalAnd`, etc. are very verbose and can be used quite frequently. But yeah this is not super important and was more of a curiosity.
The bitwise operators are not really the same because the use case I'm thinking about is when you have two `Tensor<Bool>`s and you want to perform element-wise logical operations between them.
-Anthony
On Wednesday, April 17, 2019 at 11:12:16 PM UTC-4, Chris Lattner wrote:On Apr 17, 2019, at 6:44 PM, Anthony Platanios <e.a.p...@gmail.com> wrote:
> I was wondering why there are no `.&&`, `.||`, etc. operators, similar to `.==`, `.!=`, etc. To me it felt natural trying to use `.&&` after being aware of `.==`.
&& and || in swift are short circuiting operators like in C, and always return Bool.
The “.” operators are point wise vector operators, e.g. .== is a point wise comparison, which produces a vector/tensor of boolean values.
Because point wise operators execute on every element, they can’t be short circuiting, so .&& doesn’t make sense. You can use & though to get pointwise bitwise and.
> Also, I noticed that there is an op defined in Ops.swift that is never used: `infix operator ≈ : ComparisonPrecedence`. Was that supposed to be replacing `elementsApproximatelyEqual`?
I’m not sure about that, it is probably a dead experiment that should be removed.
-Chris
On Apr 18, 2019, at 9:14 AM, Anthony Platanios <e.a.pl...@gmail.com> wrote:
Thanks Chris!That's an interesting point! Does that have any effect in how the compiler would treat say `.&&`, or is it mainly a semantics issue? Because there are two parts to the interpretation of `&&`: (i) it performs a logical and operation, and (ii) it is short-circuiting.
Given that it could not be short-circuiting for tensors when performed element-wise, using `.&&`, it could potentially still be used to perform a logical and operation. The main disadvantage to this would potentially be the expectation from users that this is short circuiting, but I don't really know how much of an issue this would be for `.&&` (assuming the convention of `.XX` being element-wise operations).My concern is that the current `elementsLogicalAnd`, etc. are very verbose and can be used quite frequently. But yeah this is not super important and was more of a curiosity.
The bitwise operators are not really the same because the use case I'm thinking about is when you have two `Tensor<Bool>`s and you want to perform element-wise logical operations between them.-Anthony
On Wednesday, April 17, 2019 at 11:12:16 PM UTC-4, Chris Lattner wrote:On Apr 17, 2019, at 6:44 PM, Anthony Platanios <e.a.p...@gmail.com> wrote:
> I was wondering why there are no `.&&`, `.||`, etc. operators, similar to `.==`, `.!=`, etc. To me it felt natural trying to use `.&&` after being aware of `.==`.
&& and || in swift are short circuiting operators like in C, and always return Bool.
The “.” operators are point wise vector operators, e.g. .== is a point wise comparison, which produces a vector/tensor of boolean values.
Because point wise operators execute on every element, they can’t be short circuiting, so .&& doesn’t make sense. You can use & though to get pointwise bitwise and.
> Also, I noticed that there is an op defined in Ops.swift that is never used: `infix operator ≈ : ComparisonPrecedence`. Was that supposed to be replacing `elementsApproximatelyEqual`?
I’m not sure about that, it is probably a dead experiment that should be removed.
-Chris