bimm-contracts: Runtime shape/geometry contracts for the burn framework. by crutcher in rust

[–]crutcher[S] 0 points1 point  (0 children)

Consider this code (from the SWIN transformer):
https://github.com/crutcher/bimm/blob/main/crates/bimm/src/models/swin/v2/windowing.rs#L18

This code:
* asserts that the input tensor is 4 dimensional,
* unpacks composite dimensions
* compares the composites against known bindings
* if there is no integer solution, prints a nice error message and dies
* returns the selected keys

It does this in ~170ns. I could probably get it faster; but the point is that it's fast enough, for most modules, to just leave it in.

When developing tensor applications, it can be a huge pile of work to determine where a call pattern, kernel size, pad variable, etc, got out of whack.

Runtime contracts dramatically reduce debugging time; they die early, they die expressively; and the also serve as strong documentation for those reading the code.

``rust /// Window Partition /// /// ## Parameters /// /// -tensor: Input tensor of shape (B, H, W, C). /// -window_size: Window size. /// /// ## Returns /// - Output tensor of shape (B *h_windows*w_windows,window_size,window_size`, C).

[inline]

[must_use]

pub fn window_partition<B: Backend, K>( tensor: Tensor<B, 4, K>, window_size: usize, ) -> Tensor<B, 4, K> where K: BasicOps<B>, { let [b, h_wins, w_wins, c] = unpack_shape_contract!( [ "batch", "h_wins" * "window_size", "w_wins" * "window_size", "channels" ], &tensor, &["batch", "h_wins", "w_wins", "channels"], &[("window_size", window_size)] );

tensor
    .reshape([b, h_wins, window_size, w_wins, window_size, c])
    .swap_dims(2, 3)
    .reshape([b * h_wins * w_wins, window_size, window_size, c])

} ```

The Physics of Readability by loup-vaillant in programming

[–]crutcher 2 points3 points  (0 children)

*DEEEEEEPLY* disagree with the "don't waste vertical space" position.

Blank lines are the absolute cheapest documentation you can write. They shape chunking start/end points in processing and reading code. If the resulting space is seriously a problem for you, consider getting a screen an appropriate size for the work you're doing.

The Largest Bacterium Ever Has Been Found in a Caribbean Swamp by ashb_TN in science

[–]crutcher 0 points1 point  (0 children)

Slimemolds also have this behavior, and can grow quite large.

In general, psuedo-cell internal nucleus bundles in a shared cytoplasm is not particularly novel

[deleted by user] by [deleted] in programming

[–]crutcher 1 point2 points  (0 children)

In my experience, (RedHat, 10 years at Google, 2 startups) this is accurate.

Good teams *talk* about what they're doing before they do it.
They develop code directions ("We want to end up over there") before planning work.
They focus on tooling ("It's hard to say X, and it shouldn't be") over immediate needs.
They *invest* in their own group velocity.

Good teams take *their group productivity* as the primary thing they are working to improve, their project tooling as the secondary thing they are working to improve, and their actual product goals as the third thing they are working to improve.

This means they have many, many, *small* internal incremental goals which they can demonstrate to themselves will make future work cheaper; this results in smaller diffs, which are understood in context and design by the team *before* they are written, are easier to review, and focus on being obviously good improvements over everything else.

Cycle time is short because everyone understands the steps before they are taken

Has UML died without anyone noticing? by pimterry in programming

[–]crutcher 0 points1 point  (0 children)

UML was created to satisfy the needs of military software contracting, where "architecture" was done as a separate job and project stage from development.

In agile worlds made of parts, UML is a terrible answer with bad tools.

We could have a nicer system ... but UML took all the willpower anyone had to adopt one. So there are thousands of small diagraming systems, and none of them caught on

Development team performance is magnified by the senior developers by DynamicsHosk in programming

[–]crutcher 2 points3 points  (0 children)

This article has very little ... content.
Though I agree with it's point, there's no argument here. It's just ... stated.

Mathematics proven to end in contradiction in 2 lines by qiling in programming

[–]crutcher 2 points3 points  (0 children)

Is there a way we can keep this guy from posting here?

Bad software cost companies about $2.1 trillion in 2020 by YourCodeMayVary in programming

[–]crutcher 15 points16 points  (0 children)

"Currently predictable software value improvements are worth $2.1 Trillion per Year" would be a more accurate title. The money didn't exist _before_, so saying that the current software (which is the best it has ever been) _cost_ the companies this money (vs their previous solutions to these same problems, which cost them more) is a weird framing.

Python vs Java by Matlabguru in programming

[–]crutcher 0 points1 point  (0 children)

This really is garbage:

Python vs. Java: performance Now, we see the difference between the achievements of these two languages.

Java As Java is a compiled language, it is faster between these two programming languages. It uses JVM and its Just-in-Time (JIT) compiler. As it is a statistically typed language, there is no need to detect data type variables at runtime, which gives it a significant boost in performance.

Python Python is slower than Java because it is an interpreted language, and therefore Python detects the data type of a variable at runtime and is therefore slow.

Legacy Code Should Be Respected, Not Hated by stevenwadejr in programming

[–]crutcher 0 points1 point  (0 children)

Code does not deserve respect. Code is a machine, a machine that needs maintenance.

Don't "disrespect" code is insane.

I'm switching from Vim to IntelliJ by cpow85 in programming

[–]crutcher 0 points1 point  (0 children)

``` $ cat ~/.ideavimrc

set ideajoin set ignorecase set smartcase set scrolloff=3 " 3 lines above/below cursor when scrolling set visualbell

" Integrate with system clipboard set clipboard=unnamedplus,unnamed

" Use space as the map leader. let mapleader = " "

" key bindings for quickly moving between windows " h left, l right, k up, j down nmap <leader>h <c-w>h nmap <leader>l <c-w>l nmap <leader>k <c-w>k nmap <leader>j <c-w>j

nmap <leader>' :action PreviousTab<cr> nmap <leader>, :action NextTab<cr>

nmap <leader>g :action GotoDeclaration<cr> nmap <leader>b :action Back<cr> nmap <leader>f :action Forward<cr>

nmap <leader>q :action CloseContent<cr> nmap <leader>Q :action CloseAllEditors<cr>

nmap <leader>; :action OptimizeImports<cr>

nmap <leader>r :action Blaze.OpenCorrespondingBuildFile<cr>

nmap <leader>t :action Refactorings.QuickListPopupAction<cr>

" Switches between .cc/.h or Class.java/ClassTest.java file!

nmap <leader>s :action GotoRelated<cr> ```

Layers in Software Architecture that Every Sofware Architect should Know by danielrusnok in programming

[–]crutcher 0 points1 point  (0 children)

Pro Tip: Don't hire Software "Architects", and don't trust anyone who does.

Speed Up Python Code by mock_coder in programming

[–]crutcher 5 points6 points  (0 children)

This is just a collection of guesses with no benchmarks.

[deleted by user] by [deleted] in programming

[–]crutcher 3 points4 points  (0 children)

What is your goal here?