Repository navigation
[RUST] RFC and 0.5 Release Plans #2306
Description
Activity
- changed the title
[-][RUST] comply with 2018 edition[/-][+][RUST] RFC and Release Plans[/+]on Dec 24, 2018 Here're my thoughts about a
commoncrate:The main difference (besides some conversions and using a fat point) between frontend and runtime
TVMArgValueandTVMRetValueis how they're wrapping/usingTVMValue. The runtimeTVMValueis raw, however, frontend needsDebug + Displayand some idiomatic conversions. Therefore,common'sTVMValuehas to be wrapped at least.Because bindgen doesn't work for runtime, so either we should
- include the generated raw c api in
commonentirely (same as runtime)
or - include what needed such as raw
TVMValueandTVMTypeCodeand then, wrap and impl required conversions for both runtime and frontend (because of Orphan rule so that we won't need more wrapper boilerplates in either crates).
- include the generated raw c api in
@nhynes I'm working on the common crate and it's completely non-obvious how to make it. I'm making minimum assumptions like even removing the debugging for
TVMValueand including it raw same as in Rust runtime. The only idea that might lead to a solution is to include the entirec_runtime_api.rsin common and get rid of mytvm-syswhich I don't like and it would impose very uncommon layout for a Rust binding. If I include some partial C runtime api such asTVMValueandTVMTypeCode, then Rust's orphan rule prevents me from conversion fromcommon::TVMValuetotvm_sys::TVMValueand need to change all occurences oftvm_sys::TVMValuein the raw api tocommon::TVMValuewhich is not possible!I'm now thinking maybe common crate is not a good idea here and we can have exactly the same functionalities with two different implementations because runtime and frontend needs are different when we include debugging for example. Note that this includes very basic value conversions API only and it's not significant.
Overall, I'll work on making a common crate this week and next maybe and if I wouldn't have found a solution by then, I'd just change the frontend
TVMRetValueto exactly match the runtime and impl the same conversions and send the PR.Any comment?
an interesting point. what happens if the
commoncrate has the headers behind one of two mutually exclusive feature flags:runtimeandfrontend? The former would pull in the definitions fromc_runtime_api.rsand the latter would exposetvm-sys.removing the debugging
I'm not sure I follow. Is it not as easy as
#[derive(Debug)]or evenimpl Debug for StructLike even if we have to do out-of-band codegen, I think that it's worth having one API. If we don't, SWIM will surely come by in a few months, read the codebase, and think "wtf. why are there two different implementations of the same thing?!?!" much as I do when reading topi code :P
I'd prefer for you to not struggle with this, so if it really becomes too onerous, just give me your acceptance criteria for the frontend "working" and I'll do my best to merge them.
what happens if the common crate has the headers behind one of two mutually exclusive feature flags: runtime and frontend?
Well, I haven't thought about that. It seems a viable approach.
I'm not sure I follow. Is it not as easy as #[derive(Debug)] or even impl Debug for Struct
I take back my debugging concern. Previously, I sort of made
TVMValueintoPartialEq + Eqby attaching a type but is not necessary and it should be fine to justimpl Debug.I'd prefer for you to not struggle with this, so if it really becomes too onerous, just give me your acceptance criteria for the frontend "working" and I'll do my best to merge them.
Thanks for the support 👍
Right now, I'm using runtime impl in
commonwith some changes in runtime. I'll update you for the frontend compatibility as it implies some good number of changes as well. Hopefully it won't be too much headache!I should say that inevitably the downside of
commonis exposing all fields ofTVMArgValue(include_lifetime) andTVMRetValuewhich might be ok for our case but need more care perhaps!- changed the title
[-][RUST] RFC and Release Plans[/-][+][RUST] RFC and 0.5 Release Plans[/+]on Jan 29, 2019
The following are the current plans for TVM Rust including both "runtime" and "frontend" as part of roadmap v0.5.
commoncrate for runtime and frontendPackedFunccompatible with frontendcall_packed!macro more general and compatible across both runtime and frontend sides as discussed.