DialectResourceBlobManager: add API to access blobMap (original) (raw)
There’s a dialect-resource management class in MLIR that allows one to store any data in binary format. It currently has the following methods:
- “lookup” a blob by key
- “update” an existing blob (practically, replace at key)
- “insert” new blob with the associated key
I propose to add an additional API:
- “get” all blobs (const method)
- could be implemented as
begin()
andend()
by forwarding the underlyingStringMap
iterators?
- could be implemented as
Motivation:
- My primary goal is to be able to see all data that’s stored in the object
- Currently, I am just curious in counting it for the sake of statistics collection
- Some time ago, I was experimenting with better memory management and such direct access could be used together with e.g.
update
(or potentiallyerase
) to eagerly release resources
- Secondary goal: potential for better printing → parsing roundtrip
- Currently, IR containing dialect resources is problematic: one cannot access the resources before full IR is parsed because AsmPrinter first prints the IR and afterwards prints still used dialect resources. With the API, we could print all dialect resources first (Note: not all of them would be used in IR at that point) and only then the IR that uses them.
Unfortunately, due to IR modifications, some dialect resources can no longer be “inferred” from the IR itself. (E.g. consider %value = Op dialect_resource<X>
being erased), which is why I find the API to be a useful addition.
I decided to start this thread to see if there’s any opposition to this or whether this was just never required before (and thus no API added originally).