Skip to content

Commit b8f874b

Browse files
author
zhangyue
committed
refactor(cpu/linear): drop redundant && bias guard + narrating comment
- `if (bias_ptr && bias)` → `if (bias_ptr)` (line 75). `bias_ptr` is `nullptr` iff `!bias` by construction at line 38, so `&& bias` is dead. - Remove `// Determine `m`, `n`, `k` from shapes and transpose flags.` — the three lines below literally do exactly that; self-describing now that names are snake_case.
1 parent 2a28bb5 commit b8f874b

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/cpu/linear/linear.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class Operator<Linear, Device::Type::kCpu> : public Linear,
3737
auto* out_ptr = static_cast<T*>(out.data());
3838
const T* bias_ptr = bias ? static_cast<const T*>(bias->data()) : nullptr;
3939

40-
// Determine `m`, `n`, `k` from shapes and transpose flags.
4140
auto ndim_a = a_shape_.size();
4241
auto ndim_b = b_shape_.size();
4342
auto ndim_out = out_shape_.size();
@@ -72,7 +71,7 @@ class Operator<Linear, Device::Type::kCpu> : public Linear,
7271
// Bias stride: for 1D bias `[n]`, stride is 1. For batched bias, use last
7372
// stride.
7473
Tensor::Stride bias_stride = 0;
75-
if (bias_ptr && bias) {
74+
if (bias_ptr) {
7675
auto ndim_bias = bias->shape().size();
7776
bias_stride = bias->strides()[ndim_bias - 1];
7877
}

0 commit comments

Comments
 (0)