Repository navigation
Adding initial vm.list implementation - #2369
Conversation
6156385 to
38aeb34
Compare
| // ABI. It is not designed for efficiency: if you are performing large amounts | ||
| // of work on the list type you should instead be representing that using the | ||
| // HAL types so that you can get acceleration. |
There was a problem hiding this comment.
Thanks for the performance note.
How would someone spot if their code hits this path? Would performance be clear in a trace file? Would it only really appear if they were writing code directly against these APIs using vm.list, or could it also happen transitively through Python code (e.g. passing (list[Tensor, Tensor, Tensor]) instead of (Tensor, Tensor, Tensor)?
There was a problem hiding this comment.
A sampling profiler/inspection would be the only way - it's like using a CHECK'd std::vector instead of std::array: each action just takes a tiny bit longer.
| // Returns the value of the element at the given index. If the specified | ||
| // |value_type| differs from the list storage type the value will be converted | ||
| // using the value type semantics (such as sign/zero extend, etc). | ||
| IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_list_get_value( | ||
| const iree_vm_list_t* list, iree_host_size_t i, | ||
| iree_vm_value_type_t value_type, iree_vm_value_t* out_value); |
There was a problem hiding this comment.
Seems odd to me that this does a conversion when the list storage type is fixed.
What about having a no conversion iree_vm_list_get_value() and a conversion helper iree_vm_list_get_value_as(), which could wrap iree_vm_list_get_value() and iree_vm_list_convert_value_type?
There was a problem hiding this comment.
The list storage type isn't always fixed; for example, if the list is storing variants the type of any particular element could be different than any other element. If the calling code supports handling arbitrary types it should use get_variant instead (and then deal with the mess), whereas this is the helper to get a value type. I don't really see many uses for a get_value that returns a somewhat-typed value, but I do like the clearer naming, so adding now and we can see if it gets used.
38aeb34 to
56a77fb
Compare
This implements the initial runtime support of the
!vm.listtype. At this point the implementation here is enough to unblock any work using the vm.list types from the current IR ops. Future changes will replace theiree_vm_variant_listwith this type as the single list type used in the VM and add additional tests/benchmarks.