-
Notifications
You must be signed in to change notification settings - Fork 60
issue/581 - 添加python的linear的实现,接口和测试 #582
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
base: main
Are you sure you want to change the base?
Conversation
c43faf3 to
7a19fff
Compare
src/infinicore/ops/linear/linear.cc
Outdated
|
|
||
| Tensor linear(Tensor input, | ||
| Tensor weight, | ||
| pybind11::object bias) { |
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.
bias 不在外部转tensor吗
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.
Pyorch的接口中, bias可能是None 或 Tensor。 为了向pytorch那样,只使用一个函数处理这两种情况。 就使用object类作为类型了, 再c++中判断是否是None,再转换
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.
回来修改: 从include中移除 pybind的头文件, 再加一个中间的函数处理none的情况
|
可以把nn::module::Linear里的compute_linear替换成这个实现 |
7a19fff to
fc2f2a0
Compare
test/infinicore/ops/linear.py
Outdated
|
|
||
| def torch_operator(self, input, weight, bias, out=None, **kwargs): | ||
| """PyTorch linear implementation""" | ||
| result = torch.nn.functional.linear(input, weight, bias) |
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.
已修改
|
|
||
| namespace py = pybind11; | ||
|
|
||
| namespace infinicore::ops::linear { |
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.
不用再起一个namespace了
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.
已修改
e6b047c to
d11927b
Compare
d11927b to
9dbf020
Compare
目标版本
main
功能描述
添加linear的实现,接口和测试
gpu测试

cpu测试
