This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-tirx.git
The following commit(s) were added to refs/heads/main by this push:
new 1527bc67f [Rust] Bump tvm-ffi to 55b4fad0 for the Rust API renames
(#202)
1527bc67f is described below
commit 1527bc67f2f769015b809a7169b3752fe7afdba4
Author: Tianqi Chen <[email protected]>
AuthorDate: Thu Nov 5 09:28:17 2026 -0500
[Rust] Bump tvm-ffi to 55b4fad0 for the Rust API renames (#202)
Bumps `3rdparty/tvm-ffi` to 55b4fad0 (apache/tvm-ffi#929) and adapts the
Rust crate to its API changes:
- `Array::new(items)` becomes `Array::from_vec(items)`; `Array::new()`
now creates an empty array.
- `UnchangedOr::value_or` becomes `value_or_unchanged`.
- `Map::contains_key` returns `Result<bool>`.
- `Array` indexing now lends `&T` in place, so `seq[i]` gives a `&Stmt`.
---
3rdparty/tvm-ffi | 2 +-
rust/examples/define_ir.rs | 2 +-
rust/src/ir/op_def.rs | 2 +-
rust/src/ir/stmt.rs | 6 +++---
rust/src/sym/constraint.rs | 2 +-
rust/src/tirx/index_map.rs | 4 ++--
rust/src/tirx/structural_map_with_constraint_context.rs | 2 +-
rust/src/tirx/tile/dispatch.rs | 2 +-
rust/tests/ir/expr.rs | 2 +-
rust/tests/ir/main.rs | 2 +-
rust/tests/ir/module.rs | 2 +-
rust/tests/ir/op_def.rs | 6 +++---
rust/tests/sym/iter_affine_map.rs | 2 +-
rust/tests/target/main.rs | 6 +++---
rust/tests/tirx/index_map.rs | 8 ++++----
rust/tests/tirx/main.rs | 5 ++++-
rust/tests/tirx/structural_visit_with_constraint_context.rs | 2 +-
rust/tests/tirx/tile/instruction.rs | 2 +-
18 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/3rdparty/tvm-ffi b/3rdparty/tvm-ffi
index b94b787b3..55b4fad05 160000
--- a/3rdparty/tvm-ffi
+++ b/3rdparty/tvm-ffi
@@ -1 +1 @@
-Subproject commit b94b787b3da8def992e210e88702c80cdb86af61
+Subproject commit 55b4fad05c39996f506c170985da2381134ef362
diff --git a/rust/examples/define_ir.rs b/rust/examples/define_ir.rs
index e77922e8d..f3a7a1398 100644
--- a/rust/examples/define_ir.rs
+++ b/rust/examples/define_ir.rs
@@ -43,7 +43,7 @@ fn first_arg_type(call: &CallObj) -> Result<Type> {
/// The variable a loop binds in its body: an index of the extent's type.
fn loop_index(call: &CallObj) -> Result<Array<Var>> {
let ty: PrimType = call.args.get(0)?.ty.clone().try_cast()?;
- Ok(Array::new(vec![Var::new("i", ty, UNKNOWN_LOC)]))
+ Ok(Array::from_vec(vec![Var::new("i", ty, UNKNOWN_LOC)]))
}
// A type, which Python constructs from its fields, `T.ExamplePair(T.int32,
T.float32)`, as it
diff --git a/rust/src/ir/op_def.rs b/rust/src/ir/op_def.rs
index e9b844e09..f094c210b 100644
--- a/rust/src/ir/op_def.rs
+++ b/rust/src/ir/op_def.rs
@@ -104,7 +104,7 @@ impl OpDef {
pub fn signature<S: Specs>(self, specs: S) -> Self {
let mut description = sig::Description::default();
specs.describe(&mut description);
- let lists = description.into_lists().map(Array::new);
+ let lists = description.into_lists().map(Array::from_vec);
let args: Vec<AnyView> = lists.iter().map(AnyView::from).collect();
let def = self.invoke("_set_signature", &args).then(|op| {
if !op.validator_is_custom() {
diff --git a/rust/src/ir/stmt.rs b/rust/src/ir/stmt.rs
index a875d2965..2847ec2a4 100644
--- a/rust/src/ir/stmt.rs
+++ b/rust/src/ir/stmt.rs
@@ -909,7 +909,7 @@ fn region_body_params(op: &Op, args: &Array<Expr>, attrs:
&DictAttrs) -> Result<
op.clone(),
args.clone(),
Some(attrs.clone().into()),
- Array::new(vec![]),
+ Array::from_vec(vec![]),
);
signature.validate()?;
let params: Array<Var> = get_body_params.call_as(&signature)?;
@@ -1015,7 +1015,7 @@ fn flatten(seq: Array<Stmt>) -> Array<Stmt> {
}
let mut flattened = Vec::new();
seq.iter().for_each(|stmt| append(stmt, &mut flattened));
- Array::new(flattened)
+ Array::from_vec(flattened)
}
/// Whether `stmt` is `Evaluate(0)`, the no-op a sequence drops (C++
`IsSeqStmtNoOp`).
@@ -1032,7 +1032,7 @@ fn into_body(stmt: Stmt) -> Result<SeqStmt> {
return Ok(tvm_ffi::ObjectRefCast::try_cast(stmt).expect("a SeqStmt"));
}
let loc = stmt.loc.clone();
- Ok(SeqStmt::from_fields(loc, flatten(Array::new(vec![stmt]))))
+ Ok(SeqStmt::from_fields(loc, flatten(Array::from_vec(vec![stmt]))))
}
// tvm-ffi-stubgen(begin): object/ir.If
diff --git a/rust/src/sym/constraint.rs b/rust/src/sym/constraint.rs
index 9661bf255..45204114e 100644
--- a/rust/src/sym/constraint.rs
+++ b/rust/src/sym/constraint.rs
@@ -416,7 +416,7 @@ impl ConstraintContextObj {
}
let mut facts = Vec::new();
self.for_each(|fact| facts.push(fact.clone()));
- Array::new(facts)
+ Array::from_vec(facts)
}
}
diff --git a/rust/src/tirx/index_map.rs b/rust/src/tirx/index_map.rs
index 52c66c631..10fd495ba 100644
--- a/rust/src/tirx/index_map.rs
+++ b/rust/src/tirx/index_map.rs
@@ -32,8 +32,8 @@
//!
//! let i = Var::new("i", PrimType::int(32), UNKNOWN_LOC);
//! let j = Var::new("j", PrimType::int(32), UNKNOWN_LOC);
-//! let final_indices = Array::new(vec![Expr::from(&j), Expr::from(&i)]);
-//! let transpose = IndexMap::new(Array::new(vec![i, j]), final_indices, None);
+//! let final_indices = Array::from_vec(vec![Expr::from(&j), Expr::from(&i)]);
+//! let transpose = IndexMap::new(Array::from_vec(vec![i, j]), final_indices,
None);
//! assert_eq!(script(&transpose)?, "T.index_map(lambda i, j: (j, i))");
//!
//! let text = |exprs: Array<Expr>| exprs.iter().map(|e|
script(&e)).collect::<Result<Vec<_>>>();
diff --git a/rust/src/tirx/structural_map_with_constraint_context.rs
b/rust/src/tirx/structural_map_with_constraint_context.rs
index d2704a60a..b37c958fe 100644
--- a/rust/src/tirx/structural_map_with_constraint_context.rs
+++ b/rust/src/tirx/structural_map_with_constraint_context.rs
@@ -107,7 +107,7 @@ where
// original path's permission. The shared engine checks live
aliases.
let replacement = MutationView::from(&mut
mapped).with_inplace_mode(mode);
let result = mutator.default_mutate(self, replacement)?;
- Ok(UnchangedOr::changed(result.value_or(mapped)))
+ Ok(UnchangedOr::changed(result.value_or_unchanged(mapped)))
} else {
// SAFETY: this private adapter runs only inside the shared engine
// callback. The engine owns the root; recursive callers keep each
diff --git a/rust/src/tirx/tile/dispatch.rs b/rust/src/tirx/tile/dispatch.rs
index 5eaca83b6..8dda2c949 100644
--- a/rust/src/tirx/tile/dispatch.rs
+++ b/rust/src/tirx/tile/dispatch.rs
@@ -170,7 +170,7 @@ impl DispatchContext {
let launch_params = launch_params
.into_iter()
.map(|(name, var, extent)| {
- (String::from(name), Array::new(vec![Any::from(var),
Any::from(extent)]))
+ (String::from(name), Array::from_vec(vec![Any::from(var),
Any::from(extent)]))
})
.collect::<Map<String, Array<Any>>>();
let scope_kind = String::from(scope_kind);
diff --git a/rust/tests/ir/expr.rs b/rust/tests/ir/expr.rs
index 0db3b8680..27cb45799 100644
--- a/rust/tests/ir/expr.rs
+++ b/rust/tests/ir/expr.rs
@@ -380,7 +380,7 @@ fn calls_agree_with_cpp() {
];
for (what, ty, op, args) in cases {
let array: Array<Expr> = args.iter().cloned().collect();
- let (attrs, ty_args) = (Option::<Attrs>::None,
Array::<Type>::new(vec![]));
+ let (attrs, ty_args) = (Option::<Attrs>::None,
Array::<Type>::from_vec(vec![]));
let native_call = native(
"ir.Call",
&[
diff --git a/rust/tests/ir/main.rs b/rust/tests/ir/main.rs
index be0cb24c2..fc056f06e 100644
--- a/rust/tests/ir/main.rs
+++ b/rust/tests/ir/main.rs
@@ -102,7 +102,7 @@ fn seq(stmts: impl IntoIterator<Item = impl Into<Stmt>>) ->
SeqStmt {
/// A function without parameters that returns `value`.
fn function(value: i64) -> BaseFunc {
- let params = Array::<Var>::new(vec![]);
+ let params = Array::<Var>::from_vec(vec![]);
let body = Some(seq([Return::new(int32(value), UNKNOWN_LOC)]));
let ret_type: Type = PrimType::int(32).into();
let attrs = DictAttrs::new(Map::new());
diff --git a/rust/tests/ir/module.rs b/rust/tests/ir/module.rs
index 792889084..0642a8849 100644
--- a/rust/tests/ir/module.rs
+++ b/rust/tests/ir/module.rs
@@ -89,7 +89,7 @@ fn modules_agree_with_cpp() {
[(FfiString::from("note"), Any::from(1i64))].into_iter().collect();
let attrs = DictAttrs::new(note);
let infos: Map<FfiString, Array<GlobalInfo>> =
- [(FfiString::from("info"), Array::new(vec![]))].into_iter().collect();
+ [(FfiString::from("info"),
Array::from_vec(vec![]))].into_iter().collect();
let cases: Vec<ModuleCase> = vec![
("IRModule", vec![(main.clone(), function(0)), (other.clone(),
function(1))], None),
("IRModule(attrs)", vec![(main.clone(), function(0))], Some(&attrs)),
diff --git a/rust/tests/ir/op_def.rs b/rust/tests/ir/op_def.rs
index 7757f05ee..30d8d2bdc 100644
--- a/rust/tests/ir/op_def.rs
+++ b/rust/tests/ir/op_def.rs
@@ -144,9 +144,9 @@ fn ops_registered_from_rust_are_used_natively() {
.call_tuple((
Option::<Type>::None,
Expr::from(&op),
- Array::<Expr>::new(vec![x.clone().into()]),
+ Array::<Expr>::from_vec(vec![x.clone().into()]),
Option::<Attrs>::None,
- Array::<Type>::new(vec![]),
+ Array::<Type>::from_vec(vec![]),
tvm_tirx::ir::Location::unknown(),
))
.unwrap()
@@ -503,7 +503,7 @@ fn launch_body_params(call: &CallObj) -> Result<Array<Var>>
{
);
return Err(Error::new(VALUE_ERROR, &message, ""));
}
- Ok(Array::new(vec![Var::new("", extent_ty, UNKNOWN_LOC)]))
+ Ok(Array::from_vec(vec![Var::new("", extent_ty, UNKNOWN_LOC)]))
}
fn no_results_or_attributes(region: &RegionStmtObj) -> Result<()> {
diff --git a/rust/tests/sym/iter_affine_map.rs
b/rust/tests/sym/iter_affine_map.rs
index 206dbecae..79b2302e5 100644
--- a/rust/tests/sym/iter_affine_map.rs
+++ b/rust/tests/sym/iter_affine_map.rs
@@ -46,7 +46,7 @@ fn mark_is(mark: &IterMark, var: &Var, extent: i64) -> bool {
#[test]
fn iter_maps_decompose_into_marks_and_splits() {
let Fixture { analyzer, x } = fixture();
- let indices = Array::new(vec![
+ let indices = Array::from_vec(vec![
op("prim._OpFloorDiv", &x, int32(4)),
op("prim._OpFloorMod", &x, int32(4)),
]);
diff --git a/rust/tests/target/main.rs b/rust/tests/target/main.rs
index d7c62763f..9740e2e0e 100644
--- a/rust/tests/target/main.rs
+++ b/rust/tests/target/main.rs
@@ -80,7 +80,7 @@ fn construction_and_queries() {
let llvm = Target::new("llvm").unwrap();
assert_eq!(llvm.kind().unwrap().name().unwrap().as_str(), "llvm");
assert_eq!(llvm.get_target_device_type().unwrap(), 1);
- assert!(llvm.export().unwrap().contains_key(&FfiString::from("kind")));
+
assert!(llvm.export().unwrap().contains_key(&FfiString::from("kind")).unwrap());
assert!(llvm.as_json().unwrap().as_str().contains("llvm"));
assert_eq!(
llvm.feature("no_such_feature").unwrap().type_index(),
@@ -95,7 +95,7 @@ fn construction_and_queries() {
let kinds = Target::list_kinds().unwrap();
assert!(kinds.iter().any(|kind| kind.as_str() == "llvm"));
let options = llvm.kind().unwrap().options().unwrap();
- assert!(options.contains_key(&FfiString::from("mtriple")));
+ assert!(options.contains_key(&FfiString::from("mtriple")).unwrap());
assert_eq!(TargetKind::options_from_name("llvm").unwrap().len(),
options.len());
}
@@ -116,7 +116,7 @@ fn tags() {
let tagged = target::register_tag("rust-test/llvm", &config("llvm"),
true).unwrap();
assert_eq!(tagged.kind().unwrap().name().unwrap().as_str(), "llvm");
let tags = target::list_tags().unwrap();
- assert!(tags.contains_key(&FfiString::from("rust-test/llvm")));
+ assert!(tags.contains_key(&FfiString::from("rust-test/llvm")).unwrap());
assert!(target::register_tag("rust-test/llvm", &config("llvm"),
false).is_err());
}
diff --git a/rust/tests/tirx/index_map.rs b/rust/tests/tirx/index_map.rs
index a3a9f45be..932fa28ee 100644
--- a/rust/tests/tirx/index_map.rs
+++ b/rust/tests/tirx/index_map.rs
@@ -31,8 +31,8 @@ fn index_maps() {
let _serial = serial();
let (i, j) = (var("i", PrimType::int(32)), var("j", PrimType::int(32)));
let transpose = IndexMap::new(
- Array::new(vec![i.clone(), j.clone()]),
- Array::new(vec![Expr::from(&j), Expr::from(&i)]),
+ Array::from_vec(vec![i.clone(), j.clone()]),
+ Array::from_vec(vec![Expr::from(&j), Expr::from(&i)]),
None,
);
let mapped = transpose.map_indices([int32(1), int32(2)], None).unwrap();
@@ -44,8 +44,8 @@ fn index_maps() {
let k = var("k", PrimType::int(32));
let split = IndexMap::new(
- Array::new(vec![k.clone()]),
- Array::new(vec![
+ Array::from_vec(vec![k.clone()]),
+ Array::from_vec(vec![
op("prim._OpFloorDiv", &k, int32(4)),
op("prim._OpFloorMod", &k, int32(4)),
]),
diff --git a/rust/tests/tirx/main.rs b/rust/tests/tirx/main.rs
index 0a250f061..84613b83e 100644
--- a/rust/tests/tirx/main.rs
+++ b/rust/tests/tirx/main.rs
@@ -97,7 +97,10 @@ fn tile_8x8() -> TileLayout {
fn void_function(params: Vec<Var>) -> Function {
let zero = global("ir.Evaluate").call_tuple((int32(0),
Location::unknown())).unwrap();
let body: SeqStmt = global("ir.SeqStmt")
- .call_tuple((Array::<Stmt>::new(vec![zero.try_into().unwrap()]),
Some(Location::unknown())))
+ .call_tuple((
+ Array::<Stmt>::from_vec(vec![zero.try_into().unwrap()]),
+ Some(Location::unknown()),
+ ))
.unwrap()
.try_into()
.unwrap();
diff --git a/rust/tests/tirx/structural_visit_with_constraint_context.rs
b/rust/tests/tirx/structural_visit_with_constraint_context.rs
index 7279bee99..7676bcf2b 100644
--- a/rust/tests/tirx/structural_visit_with_constraint_context.rs
+++ b/rust/tests/tirx/structural_visit_with_constraint_context.rs
@@ -213,7 +213,7 @@ fn
lazy_call_arms_gain_predicates_but_eager_select_arms_do_not() {
let condition = Var::new("lazy_condition", PrimType::bool(), UNKNOWN_LOC);
let lazy = prim::op::if_then_else(&condition, int32(21),
int32(22)).unwrap();
let eager = prim::Select::new(&condition, int32(31), int32(32),
UNKNOWN_LOC).unwrap();
- let root = Array::new(vec![lazy, eager.into()]);
+ let root = Array::from_vec(vec![lazy, eager.into()]);
let mut seen = Leaves::default();
visit(&root, &mut seen).unwrap();
assert_eq!(
diff --git a/rust/tests/tirx/tile/instruction.rs
b/rust/tests/tirx/tile/instruction.rs
index 0b8557b4b..9e9de4b1b 100644
--- a/rust/tests/tirx/tile/instruction.rs
+++ b/rust/tests/tirx/tile/instruction.rs
@@ -35,7 +35,7 @@ fn tensor_regions() {
TensorType::new([int32(4)], PrimType::float(32), &scope, 0, None,
UNKNOWN_LOC).unwrap();
let tensor = var("T", &ty);
let load: Expr = global("ir.TensorLoad")
- .call_tuple((Expr::from(&tensor), Array::new(vec![int32(1)]),
Location::unknown()))
+ .call_tuple((Expr::from(&tensor), Array::from_vec(vec![int32(1)]),
Location::unknown()))
.unwrap()
.try_into()
.unwrap();