Vectors vs Tensors ?

Can some one explain the difference between Mojo Vectors [ Dynamic , InlinedFixed ] and Tesnors and when to use what ?. For example if i want to create a list like structure [ think a python like list ] what should i use ?? and why ? Are there benefits of using Tensors over Vectors and vise versa ?
5 Replies
ModularBot
ModularBot9mo ago
Congrats @shamal_de_silva, you just advanced to level 2!
duckki
duckki9mo ago
Tensors can be multi-dimensional (but with a flat layout internally) and Vectors can't. Even if you can declare a vector of vector, it won't have a flat memory layout. I think tensors have special optimizations in mind, taking advantage of the flat internal structure.
shamal_de_silva
shamal_de_silva9mo ago
@duckki thank you for the response. So for list like behaviour should one go for Vectors or Tensors ? whats your opinion on that ?
Ryulord
Ryulord9mo ago
dynamic vectors can be resized like a python list while tensors have a fixed shape so vectors are definitely more list-like
shamal_de_silva
shamal_de_silva9mo ago
right so tensors can't dynamically change the size ! thank you very much for the clarrification @Ryulord :mojo:
Want results from more Discord servers?
Add your server