Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 6 additions & 7 deletions onnxscript/function_libs/torch_aten/ops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,16 +1511,15 @@ def aten_einsum(
raise NotImplementedError()


@torch_op("aten::embedding")
def aten_embedding(
weight: TensorType,
indices: TensorType,
padding_idx: int = -1,
scale_grad_by_freq: bool = False,
sparse: bool = False,
) -> TensorType:
weight: TTensor,
indices: TTensor,
**kwargs,# pylint: disable=unused-argument
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
**kwargs,# pylint: disable=unused-argument
**_,

Don’t know if ** works in onnxscript, but if it does:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to change behavior based on padding_idx?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to current implementation, it will only impact Training. I think ONNX Script won't know if current export is under Training mode, so the warning about possible wrong training result should be thrown by exporter, not onnx-script.

Thoughts?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should also support any training behaviors when possible.

) -> TTensor:
# embedding(Tensor weight, Tensor indices, int padding_idx=-1, bool scale_grad_by_freq=False, bool sparse=False) -> Tensor

raise NotImplementedError()
return op.Gather(weight, indices)


def aten_embedding_backward(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ def _topk_input_wrangler(
"nn.functional.adaptive_avg_pool2d": nn_ops.aten_adaptive_avg_pool2d,
"nn.functional.adaptive_avg_pool3d": nn_ops.aten_adaptive_avg_pool3d,
"nn.functional.elu": nn_ops.aten_elu,
"nn.functional.embedding": core_ops.aten_embedding,
"nn.functional.leaky_relu": nn_ops.aten_leaky_relu,
"nn.functional.linear": nn_ops.aten_linear,
"nn.functional.logsigmoid": nn_ops.aten_log_sigmoid,
Expand Down