Bruce Lee's Notes

Systems, programming, and engineering practice

Subtracting Zero Can Disappear; Subtracting from Zero Cannot

Keep constant folding, commutativity, and operand direction as separate decisions.

Series contents · Operators and Layouts · 阅读中文版 “Can we write subtraction the same way as addition?” Most interfaces do look alike. Both have two inputs and one output; both need data types, addres......

The First Row Works, the Second Disappears: Alignment, Strides, and Padded Constants

Make logical widths, physical strides, padded storage, and parameter layouts agree.

Series contents · Operators and Layouts · 阅读中文版 “The first row is perfect. From the second row onward, it looks like a lottery.” That is often a rather helpful error: the result’s structure is alre......

Broadcasting: Sometimes the Right Address Is the One That Does Not Move

Build per-axis address plans for scalars, lower-rank inputs, and more complex broadcasts.

Series contents · Operators and Layouts · 阅读中文版 “The framework does this in one line. Why does the backend need so many cases?” The mathematical definition of broadcasting is compact: align dimensi......

When the Debugger Starts Lying: One Permute, Three Ways to Fix Dump

Three alternative branch fixes show why observation paths need layout contracts too.

Series contents · Operators and Layouts · 阅读中文版 “The numbers are wrong.” “How do you know?” “Dump told me.” This is a good moment to pause. Dump can show bytes, but it cannot automatically guarante......

Why Does Reshape Need Code? The Elements Stay the Same; Their Route Changes

Prove the linear element mapping and distinguish shape changes from physical rearrangement.

Series contents · Operators and Layouts · 阅读中文版 “Not a single element is missing. Why does the compiler say this is unsupported?” Reshape hears this accusation often. The model author sees the same......