Skip to content

Adding initial vm.list implementation - #2369

Merged
benvanik merged 3 commits into
mainfrom
benvanik-vm-list
Jul 9, 2020
Merged

benvanik merged 3 commits into
mainfrom
benvanik-vm-list

Conversation

@benvanik

@benvanik benvanik commented Jul 1, 2020

Copy link
Copy Markdown
Collaborator

This implements the initial runtime support of the !vm.list type. 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 the iree_vm_variant_list with this type as the single list type used in the VM and add additional tests/benchmarks.

@benvanik benvanik added enhancement ➕ New feature or request runtime Relating to the IREE runtime library labels Jul 1, 2020
@benvanik benvanik added this to the 2020Q2 Core milestone Jul 1, 2020
@benvanik
benvanik force-pushed the benvanik-vm-list branch from 6156385 to 38aeb34 Compare July 1, 2020 01:37
@benvanik
benvanik marked this pull request as ready for review July 1, 2020 01:57
@benvanik
benvanik requested a review from ScottTodd July 1, 2020 01:57
Comment thread iree/vm/test/list_ops.mlir Resolved
Comment thread iree/vm/list.h
Comment on lines +33 to +35
// 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread iree/vm/list.h Resolved
Comment thread iree/vm/list.h
Comment on lines +78 to +90
// 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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread iree/vm/list_test.cc Resolved
Comment thread iree/vm/list.c Resolved
@benvanik
benvanik force-pushed the benvanik-vm-list branch from 38aeb34 to 56a77fb Compare July 9, 2020 19:57
@benvanik
benvanik merged commit 12873ec into main Jul 9, 2020
@benvanik
benvanik deleted the benvanik-vm-list branch July 9, 2020 20:22
@GMNGeoffrey GMNGeoffrey mentioned this pull request Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ➕ New feature or request runtime Relating to the IREE runtime library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants