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

[Rust] Fixup rust bindings #16712

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

cgerum
Copy link
Contributor

@cgerum cgerum commented Mar 13, 2024

This is a rework of #16628 it does not introduce new bindings, but only adopts to some changes in the TVM API, by adding missing attribute values.

@jroesch @nhynes could you have a look.

@cgerum cgerum changed the title WIP: [Rust] Fixup rust bindings [Rust] Fixup rust bindings Mar 13, 2024
@cgerum
Copy link
Contributor Author

cgerum commented Mar 31, 2024

@Lunderberg @tqchen any chance you know somebody who could review?

Copy link
Contributor

@Lunderberg Lunderberg left a comment

Choose a reason for hiding this comment

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

I'm not too familiar with the TVM Rust bindings, but the changes look reasonable overall. I've made a couple of comments, but it would be good to get eyes from somebody more familiar with the Rust bindings as well. (@jroesch, maybe?)

}
}

impl Attrs {
Copy link
Contributor

Choose a reason for hiding this comment

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

On the C++ side, most Attrs are constructed using their subclass, not as a BaseAttrsNode. Is this a difference that we want to have between the C++ and Rust bindings?

@@ -94,9 +94,9 @@ external! {
fn _as_text(object: ObjectRef, show_meta_data: i32, annotate: runtime::Function) -> TString;
}

pub fn as_text<T: IsObjectRef>(object: T) -> String {
pub fn as_text<T: IsObjectRef>(object: T, show_meta_data: i32) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Does the new argument break existing callsites of as_text? Since we can't add default parameters to preserve backwards compatibility, I'm wondering if this should be updated to use the builder pattern in the future.
  2. Should the argument be show_meta_data: bool instead of show_meta_data: i32? The FFI cannot currently distinguish between the two, but exposing it as i32 in the Rust bindings seems odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does the new argument break existing callsites of as_text? Since we can't add default parameters to preserve backwards compatibility, I'm wondering if this should be updated to use the builder pattern in the future.

You mean object.with_metadata().as_text()? Unfortunately I am not sure wether backwards compatibility in this case is important enough, to warrant the increased API complexity.

impl From<i32> for PrimExpr {
fn from(i: i32) -> PrimExpr {
IntImm::from(i).upcast()
}
}

impl Into<i64> for PrimExpr {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should provide Into<i64> for PrimExpr, because Into should only be used for infallible conversions. Can we provide TryInto<i64> instead?

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

Successfully merging this pull request may close these issues.

None yet

2 participants