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

[lang] Fix the element_type of the AnyArray #8192

Merged
merged 5 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/taichi/lang/any_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def layout(self):

def get_type(self):
return NdarrayTypeMetadata(
self.ptr.get_ret_type().ptr_removed(), None, _ti_core.get_external_tensor_needs_grad(self.ptr)
_ti_core.get_external_tensor_element_type(self.ptr), None, _ti_core.get_external_tensor_needs_grad(self.ptr)
) # AnyArray can take any shape

@property
Expand Down
6 changes: 6 additions & 0 deletions taichi/python/export_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,12 @@ void export_lang(py::module &m) {
return expr.cast<ExternalTensorExpression>()->needs_grad;
});

m.def("get_external_tensor_element_type", [](const Expr &expr) {
TI_ASSERT(expr.is<ExternalTensorExpression>());
auto external_tensor_expr = expr.cast<ExternalTensorExpression>();
return external_tensor_expr->dt;
});

m.def("get_external_tensor_element_shape", [](const Expr &expr) {
TI_ASSERT(expr.is<ExternalTensorExpression>());
auto external_tensor_expr = expr.cast<ExternalTensorExpression>();
Expand Down