Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting data before DL reads it. #65

Closed
lundmark opened this issue Dec 6, 2017 · 10 comments
Closed

Converting data before DL reads it. #65

lundmark opened this issue Dec 6, 2017 · 10 comments

Comments

@lundmark
Copy link
Collaborator

lundmark commented Dec 6, 2017

Hey!

So the issue is that we want to be able to specify things in strings in our intermediate format (for example, we want to have paths to resources, or use intermediate-resource-id's), these we want to convert to id's that are used in runtime.

So our structs might look like:
struct MyOB { uint64_t path; }

Where the path is something we want to specify as a string in the intermediate (json) format:
"MyOB" : {
"path" : "/my/path/object"
}

Now the best suggestion or idea I have is basically tagging them like this:

"path" : #PATH"/my/path/object"

and then when I read the file, before DL parses it, I just go through it all and see if I can find any such strings to convert.

I would love to see a "better" or more proper way to solve this longterm that is sustainable and useable for DL as well.

@wc-duck
Copy link
Owner

wc-duck commented Dec 6, 2017

That is really a though question and I'm not really sure I want to add custom packing callbacks per member as that would spread throughout the codebase.

Also, how would that work with unpacking to text? Now the user would have to be able to provide reverse ops as well.

dlpack.exe will also have to be custom built.

Lastly, how would you specify the data in the tld as text has one type and binary another?

At home I just specify to formats, one intermediate and one runtime and have my own compiler in the middle. IMHO that is a better solution as you can tailor the intermediate format for editing and the runtime format for runtime.

But maybe there is something dl can help out with in the process of im -> runtime?

@wc-duck
Copy link
Owner

wc-duck commented Dec 6, 2017

String to hash as its own type might be something that can be done but with some caveats.

Hash would be it's own type "hash32" or "hash64" in the tld, it would be specified as a string or int in text and always unpack as int (as there is no reverse lookup).
The hash-function used would be decided by dl BUT overridable at compile-time.

But I do not know if such a type would be useful?

@wc-duck
Copy link
Owner

wc-duck commented Dec 6, 2017

Just a quick thought... That I haven't worked through in my head yet. But maybe one thing that dl could help out with somehow is to be able to define some kind of alias for the basic types.

So that you could define the type "path" or "uuid", specify that in your intermediate format, and detect in your code that this type should be handled as a path?

@wc-duck
Copy link
Owner

wc-duck commented Dec 6, 2017

... but it would otherwise just work as a string throughout dl

@lundmark
Copy link
Collaborator Author

lundmark commented Dec 7, 2017

Hmmm, I'm not very fond of the hash-function solution as that is extremely rigid.

What I think could be interesting if there was a way to create types that have a certain text-format and a certain binary-format, and some way to convert between these. It's the conversion that I'm uncertain of how it would actually work.

I'll try to formalize something when we come further in using DL. Currently I'll just make sure to analyze our intermediate format before passing it to DL.

@joeldevahl
Copy link
Collaborator

joeldevahl commented Dec 7, 2017 via email

@lundmark
Copy link
Collaborator Author

I've written a small parser that I use in my compiler which converts intermediate data (text) to runtime data (binary). It just does a pre-pass on the text to parse simple tags:
"path": $ID64:"/my/path/to/my/file"

path is of type uint64, of course.

This works really fine with a multiple of different things which I use. It's just a simple header file so if anyone wants it, I'll clean it out for public view and share it.

@wc-duck
Copy link
Owner

wc-duck commented Dec 18, 2017

That absolutely sounds like a great tool but for now I think it make sense as an extension/lib ontop of DL. I would love to see it btw!

And if used by more people I might consider adopting it in the official report.

@lundmark
Copy link
Collaborator Author

Yes for sure external and not a part of DL.

I will try to get some time to clean it up and make it actually useable. Right now it depends on internal types that we use (strings/allocators). I'll try to make an external header for it.

@wc-duck
Copy link
Owner

wc-duck commented May 16, 2018

I'll close this issue now since I consider it won't fix.

@wc-duck wc-duck closed this as completed May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants