Explicit parentheses around some logical operators (#1732)

* fix some warnings

* format
This commit is contained in:
Valentin Roussellet 2024-12-24 07:02:20 -08:00 committed by GitHub
parent ebfe64b92d
commit 88f993da38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 6 deletions

View File

@ -119,7 +119,7 @@ void array::eval() {
}
bool array::is_tracer() const {
return array_desc_->is_tracer && in_tracing() || retain_graph();
return (array_desc_->is_tracer && in_tracing()) || retain_graph();
}
void array::set_data(allocator::Buffer buffer, Deleter d) {

View File

@ -28,8 +28,8 @@ BinaryOpType get_binary_op_type(const array& a, const array& b) {
} else if (b.data_size() == 1 && a.flags().contiguous) {
bopt = BinaryOpType::VectorScalar;
} else if (
a.flags().row_contiguous && b.flags().row_contiguous ||
a.flags().col_contiguous && b.flags().col_contiguous) {
(a.flags().row_contiguous && b.flags().row_contiguous) ||
(a.flags().col_contiguous && b.flags().col_contiguous)) {
bopt = BinaryOpType::VectorVector;
} else {
bopt = BinaryOpType::General;

View File

@ -605,7 +605,7 @@ void View::eval_cpu(const std::vector<array>& inputs, array& out) {
// - type size is the same
// - type size is smaller and the last axis is contiguous
// - the entire array is row contiguous
if (ibytes == obytes || obytes < ibytes && in.strides().back() == 1 ||
if (ibytes == obytes || (obytes < ibytes && in.strides().back() == 1) ||
in.flags().row_contiguous) {
auto strides = in.strides();
for (int i = 0; i < static_cast<int>(strides.size()) - 1; ++i) {

View File

@ -440,7 +440,7 @@ void View::eval_gpu(const std::vector<array>& inputs, array& out) {
// - type size is the same
// - type size is smaller and the last axis is contiguous
// - the entire array is row contiguous
if (ibytes == obytes || obytes < ibytes && in.strides().back() == 1 ||
if (ibytes == obytes || (obytes < ibytes && in.strides().back() == 1) ||
in.flags().row_contiguous) {
auto strides = in.strides();
for (int i = 0; i < static_cast<int>(strides.size()) - 1; ++i) {

View File

@ -157,7 +157,7 @@ array arange(
// Check if start and stop specify a valid range because if not, we have to
// return an empty array
if (std::isinf(step) &&
(step > 0 && start < stop || step < 0 && start > stop)) {
((step > 0 && start < stop) || (step < 0 && start > stop))) {
return array({start}, dtype);
}