Francesco
Francesco
MModular
Created by Francesco on 2/24/2024 in #questions
Question from a low level memory management noob
I am trying to get familiar with some concepts for low level memory management. Coming from python this is all new for me although I do grasp the basics. I was playing around with tensors and buffers and seeing something that I find very strange so maybe understanding why this program behaves like this will hopefully help me understand something new 🙂 the first time I call print(abuf[2]) yields the correct value (2.0). The second time it's a random number. Why does this happen? `py from tensor import Tensor alias type = DType.float32 fn main(): var a = Tensor[type](100) for i in range(100): a[i] = i let abuf = a._to_buffer() print(abuf[2]) # 2.0 print(a[2]) # 2.0 print(a[2]) # 2.0 print(abuf[2]) # some random number... why?
6 replies