-
Notifications
You must be signed in to change notification settings - Fork 662
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
Dev norm op #5178
Dev norm op #5178
Conversation
#4108 之前写过一点norm的分析(PR还没合并),可以参考下 |
Examples:: | ||
|
||
>>> import oneflow.experimental as flow | ||
>>> from oneflow.experimental import linalg as LA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码你有测试过吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯,测过的。PR 一开始有结果的截图
oneflow/python/nn/modules/norm.py
Outdated
|
||
|
||
@oneflow_export("linalg.norm") | ||
@register_tensor_op("linalg.norm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
单测里面没测到 tensor.linglg.norm
背景
开发
nn.tripletmarginloss
过程中涉及求范数操作,之前实现方式直接在 loss 中实现部分范数计算。新增 Norm 算子,与 pytorch 中
torch.linalg.norm
以及numpy.linalg.norm
对齐。之前也有一个类似未合并的 PR #4108
所需算子
存在疑问
dim = None
情况下,pytorch 输出为一个shape
为 0 的tensor(xxx)
,而 oneflow 默认的输出是一个shape
为 1 的tensor([xxx])
。这个设置也会影响到keepdim = True
是的输出判定情况(已在微信群和 @Flowingsun007 沟通记录过此问题)。进度