Skip to content
Lex Fridman PodcastLex Fridman Podcast

Chris Lattner: Compilers, LLVM, Swift, TPU, and ML Accelerators | Lex Fridman Podcast #21

Chris Lattner is a senior director at Google working on several projects including CPU, GPU, TPU accelerators for TensorFlow, Swift for TensorFlow, and all kinds of machine learning compiler magic going on behind the scenes. He is one of the top experts in the world on compiler technologies, which means he deeply understands the intricacies of how hardware and software come together to create efficient code. He created the LLVM compiler infrastructure project and the CLang compiler. He led major engineering efforts at Apple, including the creation of the Swift programming language. He also briefly spent time at Tesla as VP of Autopilot Software during the transition from Autopilot hardware 1 to hardware 2, when Tesla essentially started from scratch to build an in-house software infrastructure for Autopilot. Thank you for listening ❤ Check out our sponsors: https://lexfridman.com/sponsors/ep21-sb See below for timestamps, and to give feedback, submit questions, contact Lex, etc. *CONTACT LEX:* *Feedback* - give feedback to Lex: https://lexfridman.com/survey *AMA* - submit questions, videos or call-in: https://lexfridman.com/ama *Hiring* - join our team: https://lexfridman.com/hiring *Other* - other ways to get in touch: https://lexfridman.com/contact *OUTLINE:* 0:00 - Introduction 1:30 - First program, BASIC, Pascal, C 4:20 - Compilers, LLVM, CLang 37:30 - Apple - LLVM, Objective-C, Swift 45:30 - Google - Swift, Swift for TensorFlow, compilers, Colab 57:32 - TPU & TensorFlow, hardware/software co-design 1:00:30 - MLIR (Multi-Level Intermediate Representation) framework 1:02:40 - Open sourcing of TensorFlow 1:05:10 - Tesla - transition from HW1 to HW2 1:07:24 - Elon Musk and time at Tesla 1:08:45 - Working hard 1:10:40 - Dragons *PODCAST LINKS:* - Podcast Website: https://lexfridman.com/podcast - Apple Podcasts: https://apple.co/2lwqZIr - Spotify: https://spoti.fi/2nEwCF8 - RSS: https://lexfridman.com/feed/podcast/ - Podcast Playlist: https://www.youtube.com/playlist?list=PLrAXtmErZgOdP_8GztsuKi9nrraNbKKp4 - Clips Channel: https://www.youtube.com/lexclips *SOCIAL LINKS:* - X: https://x.com/lexfridman - Instagram: https://instagram.com/lexfridman - TikTok: https://tiktok.com/@lexfridman - LinkedIn: https://linkedin.com/in/lexfridman - Facebook: https://facebook.com/lexfridman - Patreon: https://patreon.com/lexfridman - Telegram: https://t.me/lexfridman - Reddit: https://reddit.com/r/lexfridman

Lex FridmanhostChris Lattnerguest
May 13, 20191h 13mWatch on YouTube ↗

EVERY SPOKEN WORD

  1. 0:001:10:40

    Intro

    1. LF

      The following is a conversation with Chris Lattner. Currently, he's a senior director at Google working on several projects, including CPU, GPU, TPU accelerators for TensorFlow, Swift for TensorFlow, and all kinds of machine learning compiler magic going on behind the scenes. He's one of the top experts in the world on compiler technologies, which means he deeply understands the intricacies of how hardware and software come together to create efficient code. He created the LLVM Compiler Infrastructure Project and the Clang compiler. He led major engineering efforts at Apple, including the creation of the Swift programming language. He also briefly spent time at Tesla as vice president of Autopilot Software during the transition from Autopilot Hardware 1.0 to Hardware 2.0, when Tesla essentially started from scratch to build an in-house software infrastructure for Autopilot. I could have easily talked to Chris for many more hours. Compiling code down across the levels of abstraction is one of the most fundamental and fascinating aspects of what computers do, and he is one of the world experts in this process. It's rigorous science, and it's messy, beautiful art. This conversation is part of The Artificial Intelligence Podcast. If you enjoy it, subscribe on YouTube, iTunes, or simply connect with me on Twitter @lexfridman, spelled F-R-I-D. And now here's my conversation with Chris Lattner. What was the first program you've ever written?

    2. CL

      My first program-

    3. LF

      Hmm, back. And when was it?

    4. CL

      I think I started as a kid, and my parents got a BASIC programming book. And so when I started, it was typing out programs from a book, and seeing how they worked, and then typing them in wrong and trying to figure out why (laughs) they were not working right, that kinda stuff.

    5. LF

      So BASIC. What was the first language that you remember yourself maybe falling in love with, like really connecting with?

    6. CL

      Oh. I don't know, I mean, I feel like I've learned a lot along the way and, and each of them have a different special thing about them. So I started in BASIC and then went, like, GW-BASIC, which was the thing back in the DOS days, and then upgraded to QBasic and eventually QuickBASIC, which are all slightly more fancy versions of Microsoft BASIC. Um, made the jump to Pascal and started doing machine language programming in Assembly in Pascal, which was really cool. Turbo Pascal was amazing for its day. Um, eventually got into C, C++, and then kinda did lots of other weird things, so.

    7. LF

      I feel like you took the dark path, which is the, uh... You coulda, you coulda gone Lisp.

    8. CL

      Yeah, yeah.

    9. LF

      You coulda gone higher level-

    10. CL

      Yeah.

    11. LF

      ... sort of functional, philosophical, hippie route.

    12. CL

      Yeah.

    13. LF

      Instead, you went into, like, the dark arts-

    14. CL

      Yeah.

    15. LF

      ... of the C++.

    16. CL

      It was straight, straight into the machine, right?

    17. LF

      Straight to the machine.

    18. CL

      And so I s- so started with BASIC, Pascal, and then Assembly, and then wrote a lot of Assembly. And, um-

    19. LF

      Why? How?

    20. CL

      Eventually, eventually did Smalltalk and other things like that.

    21. LF

      Yeah. (laughs)

    22. CL

      But that was not the starting point.

    23. LF

      But, so what, uh, what is this journey into C? Is that in high school? Is that in college?

    24. CL

      That was in high school, yeah. So, and, and then that was, uh, it was really about trying to be able to do more powerful things than what Pascal could do and also to learn a different world. C was really confusing to me with the pointers and the syntax and everything, and it took a while. But Pascal's much more principled in various ways. C is more the, I mean, it has its historical roots, but it's, it's not as easy to learn.

    25. LF

      With pointers, there's this memory management thing that you have to become conscious of. Is that the first time you start to understand that there's resources that you're supposed to manage?

    26. CL

      Yeah. Uh, well, so you have that in, in Pascal as well, but in Pascal, they s- like the caret instead of the star and thing. There's some small differences like that, but it's not about, uh, pointer arithmetic. In p- in, in C, it, you end up thinking about how things get laid out in memory a lot more.

    27. LF

      Mm-hmm.

    28. CL

      And so in Pascal, you have allocating and deallocating and owning the, the memory, but just the programs are simpler and you don't have to... Well, for example, Pascal has a string type, and so you can think about a string instead of an array of characters which are consecutive in memory, yeah? So it's a little bit of a higher level abstraction.

    29. LF

      So, uh, let's get into it. Let's talk about-

    30. CL

      Yeah.

  2. 1:10:401:13:11

    Dragons

    1. CL

    2. LF

      So last question. LLVM logo is a dragon.

    3. CL

      Yeah.

    4. LF

      You explain that this is because dragons have connotations of power, speed, intelligence. It can also be sleek, elegant, and modular, though you remove the, the modular part. What is your favorite dragon-related character from fiction, video, or movies?

    5. CL

      So those are all very kind ways of explaining it. The... Do you wanna know the real reason it's a dragon?

    6. LF

      Well, y- yeah. Yeah, let's... (laughs)

    7. CL

      (laughs) Is that better? So there's a, a seminal book on compiler design called The Dragon Book. And so this is a really old now, uh, book on compilers. And so, um-

    8. LF

      (laughs)

    9. CL

      ... th- the, the dragon logo for LLVM came about because at Apple we kept talking about LLVM-related technologies and there was no logo to put on a slide.

    10. LF

      Right. (laughs) Yeah.

    11. CL

      And so we're like, "What, what do we do?" And somebody's like, "Well, what kind of logo should a compiler technology have?" And I'm like, "I don't know. I mean, the dragons are... a dragon is the best thing that, that we've got." And, you know, Apple somehow magically came up with the logo and-

    12. LF

      (laughs)

    13. CL

      ... and it was a great thing and the whole community rallied around it. And, uh, and then it got better as other graphic designers got involved. But that's, that's originally where it came from.

    14. LF

      Good story.

    15. CL

      Yeah.

    16. LF

      Is there dragons from fiction that you connect with for, uh, that, uh-

    17. CL

      Yeah.

    18. LF

      ... Game of Thrones, Lord of the Rings, that kind of thing?

    19. CL

      Uh, Lord of the Rings is great. I also like role-playing games and things like inpu- computer role-playing games. And so dragons often show up in there. But, but really it comes back to, uh, to...

    20. LF

      To the book.

    21. CL

      Oh no, we need, we need a thing. What do we do?

    22. LF

      Yeah.

    23. CL

      And, and hilariously, one of the, one of the, the funny things about LLVM is that my wife, who's amazing, runs the, the LLVM Foundation, and she goes to Grace Hopper and is trying to get more women involved in the... She's also a compiler engineer, so she's trying to get other, other women to get interested in compilers and things like this. And so she hands out the stickers and people like the LLVM sticker because of Game of Thrones.

    24. LF

      (laughs)

    25. CL

      And so sometimes culture has this-

    26. LF

      Yeah.

    27. CL

      ... helpful effect to, like, get the next generation of compiler engineers engaged f- with the cause.

    28. LF

      (laughs) Okay. Awesome. Chris, thanks so much for talking to me today.

    29. CL

      Yeah, it's been great talking with you.

Episode duration: 1:13:05

Install uListen for AI-powered chat & search across the full episode — Get Full Transcript

Transcript of episode yCd3CzGSte8

Get more out of YouTube videos.

High quality summaries for YouTube videos. Accurate transcripts to search & find moments. Powered by ChatGPT & Claude AI.