TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: I wrote an autodiff in C++ and implemented LeNet with it

36 pointsby mebassett7 months ago

2 comments

tightbookkeeper7 months ago
using new for each node and value, combined with virtual dispatch tends to be a c++ anti-pattern. It looks like you are writing other languages in C++ syntax, motivated by promises of speed.<p>The actual benefits of C++ come when you approach problems differently. This is a case where more exposure to C helps you avoid all the Java isms.<p>Things to consider:<p>- can you allocate memory for the whole system? - can you make types homogenous so they can fit in tight arrays (unions are common for nodes) - can you batch similar types - specially for auto diff&#x2F;math can you represent operations as a stack instead of a tree?<p>I am only bringing this up because you said your goal was to learn C++.
评论 #41877967 未加载
评论 #41888674 未加载
评论 #41877847 未加载
einpoklum7 months ago
The actual C++&#x2F;CUDA code is here:<p><a href="https:&#x2F;&#x2F;gitlab.com&#x2F;mebassett&#x2F;quixotic-learning&#x2F;-&#x2F;tree&#x2F;master&#x2F;silly_autodiff" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;mebassett&#x2F;quixotic-learning&#x2F;-&#x2F;tree&#x2F;master...</a><p>about 1,000 LoC overall.