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

fix issue #278 in relax.op.masked_fill #279

Closed
wants to merge 7 commits into from

Conversation

sbwww
Copy link
Contributor

@sbwww sbwww commented Aug 3, 2023

adding dtype argument when calling _ffi_api.full_like

tqchen and others added 6 commits August 1, 2023 10:32
MLC local ci setup.
This PR adds CI for Windows and macOS building, which may take 90-100
mins.

Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
- Enable `groups` as parameters of `conv1d`
- Update the output shape of conv2d.
This PR introduces Conv1dTranspose to relax.

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-15-248.us-west-2.compute.internal>
adding dtype argument when calling _ffi_api.full_like
@@ -34,5 +34,5 @@ def masked_fill(x: Expr, mask: Expr, value: Expr):
result : relax.Expr
The filled tensor.
"""
values = _ffi_api.full_like(x, value) # type: ignore
values = _ffi_api.full_like(x, value, x.struct_info.dtype) # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

Here it’s better to use the Python interface of full_like than the FFI interface, because the Python interface has clear semantics on the dtype, and the dtype can be None, which means being the same as the input dtype.

def full_like(x: Expr, fill_value: Expr, dtype: Optional[Union[str, DataType]] = None) -> Expr:
"""Construct a tensor such that
- its shape is the same as the input data tensor's shape,
- its value is filled with the input scalar fill value.
Parameters
----------
x : relax.Expr
The input tensor, which provides the shape, and dtype
when the `dtype` field is not specified.
fill_value : relax.Expr
The value to fill. Must be a scalar tensor.
dtype : Optional[Union[str, DataType]]
The data type of the created tensor.
If dtype is not given, it will by default use the dtype of the input tensor.
Returns
-------
result : relax.Expr
The result tensor.
"""
return _ffi_api.full_like(x, fill_value, dtype) # type: ignore

So here we can do from .create import full_like, and use values = full_like(x, value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion, please check the update.

@MasterJH5574 MasterJH5574 linked an issue Aug 3, 2023 that may be closed by this pull request
@MasterJH5574
Copy link
Member

Thanks @sbwww for the fix! Just merged the corresponding PR in apache/tvm. We have a routine-based synchronization with TVM Unity branch, and will bring that commit to this repo in the next round of sync. So please allow me to close this PR :-)

@MasterJH5574
Copy link
Member

It has now been brought in.

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.

[Bug] Error in relax.op.masked_fill and _ffi_api.full_like function
5 participants