3 ms·
Also it's common implicitly in typical representation of images as inputs to neural nets. For funsies I asked chatgpt 4o to try: uint16_t product = x * 25
by Y_Y 2y ago
Also it's common implicitly in typical representation of images as inputs to neural nets.
For funsies I asked chatgpt 4o to try:
uint16_t product = x * 257; // Multiply by 257
return product >> 16; // Shift right by 16 bits
A valiant effort, and confidently presented. When pressed and given the methods from the article to compare with it admitted it may suffer from precision issues, but was ultimately the best of the three.
The Achilles heel of this approach (and of blindly trusting LLM code in general) is left as an exercise.
- Y_Y 2y agoOk, with o1 and some careful prompting I got the following, which seems equivalent to the first approach from the article: float uint8_div_255(uint8_t x) { uint32_t y = x * 0x010101u; // x * 65793 return ((float)y) * (1.0f / 16777215.0f); }
- andrepd 2y agoSpending a drum of oil's worth of energy and knowing the answer beforehand, you too can get an LLM to print you a plausible but wrong snippet of code.
- jiggawatts 2y agoI was about to debate the “drum of oil” quip, but thinking about it: the o1 model can cost tens of dollars for a long back-and-forth conversation. A barrel of oil is currently $70, so if you’ve spent more than that on your chat, you’ve gone through an “energy slave for a year” in a matter of minutes! (A barrel of oil contains the same energy as the work done by a human labourer over a year.) Note: You might argue that most of the cost is due to the rental on the chips and not the electrical bill. Sure, but a silicon chip has a minuscule material cost and is mostly expensive because of the energy-intensive processes required to make it.