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] Hide dtype and needs_grad from SNode #4308

Merged
merged 1 commit into from
Feb 17, 2022
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/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def dtype(self):
Returns:
DataType: Data type of each individual value.
"""
return self.snode.dtype
return self.snode._dtype

@property
def name(self):
Expand Down
2 changes: 1 addition & 1 deletion python/taichi/lang/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def calc_dynamic_index_stride(self):
length = len(paths[0])
if any(
len(path) != length or ti_core.is_custom_type(path[length -
1].dtype)
1]._dtype)
for path in paths):
return
for i in range(length):
Expand Down
11 changes: 1 addition & 10 deletions python/taichi/lang/snode.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _path_from_root(self):
return res

@property
def dtype(self):
def _dtype(self):
"""Gets the data type of `self`.

Returns:
Expand Down Expand Up @@ -255,15 +255,6 @@ def snode(self):
"""
return self

@property
def needs_grad(self):
"""Checks whether `self` has a corresponding gradient :class:`~taichi.lang.SNode`.

Returns:
bool: Whether `self` has a corresponding gradient :class:`~taichi.lang.SNode`.
"""
return self.ptr.has_grad()

def _get_children(self):
"""Gets all children components of `self`.

Expand Down