Skip to content

Commit 5bcc7f5

Browse files
authored
[REFACTOR] Update data type rewriter to enable recursive rewrite in Any (#18197)
This PR updates the data type rewriter so recursive rewrite happens in Any instead of ObjectRef.
1 parent 49e519e commit 5bcc7f5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/tir/ir/data_type_rewriter.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,17 @@ Map<String, ffi::Any> IndexDataTypeRewriter::VisitBlockAnnotations(
373373
const Map<String, ffi::Any>& annotations) {
374374
auto new_annotations = annotations;
375375

376-
std::function<ObjectRef(const ObjectRef&)> f_mutate_obj =
377-
[this, &f_mutate_obj](const ObjectRef& obj) -> ObjectRef {
378-
if (!obj.defined()) {
376+
std::function<Any(const Any&)> f_mutate_obj = [this, &f_mutate_obj](const Any& obj) -> Any {
377+
if (obj == nullptr) {
379378
return obj;
380379
}
381-
if (obj->IsInstance<BufferNode>()) {
380+
if (obj.as<BufferNode>()) {
382381
Buffer buffer = Downcast<Buffer>(obj);
383382
if (Buffer new_buffer = GetRemappedBuffer(buffer); !new_buffer.same_as(buffer)) {
384383
return new_buffer;
385384
}
386-
} else if (obj->IsInstance<ffi::ArrayObj>()) {
387-
return Downcast<Array<ObjectRef>>(obj).Map(f_mutate_obj);
385+
} else if (obj.as<ffi::ArrayObj>()) {
386+
return Downcast<Array<Any>>(obj).Map(f_mutate_obj);
388387
}
389388
return obj;
390389
};

0 commit comments

Comments
 (0)