Skip to content

Issue/517 InfiniCore 添加 nn::module c++接口 &&线性层实现#531

Merged
PanZezhong1725 merged 3 commits into
mainfrom
issue/517
Oct 31, 2025
Merged

Issue/517 InfiniCore 添加 nn::module c++接口 &&线性层实现#531
PanZezhong1725 merged 3 commits into
mainfrom
issue/517

Conversation

@Ceng23333
Copy link
Copy Markdown
Collaborator

Comment thread include/infinicore/nn/linear.hpp
Comment thread include/infinicore/nn/module.hpp Outdated
Comment thread src/infinicore/nn/linear.cc Outdated
@PanZezhong1725
Copy link
Copy Markdown
Collaborator

@wooway777 @pengcheng888 这个测试里用到all close了,我觉得这应该是在tensor级别甚至时op级别需要实现的功能,而不应该测试框架单独实现,哪怕先数据全copy到cpu糊一个

Comment thread src/infinicore/nn/linear.cc Outdated
@Ceng23333 Ceng23333 force-pushed the issue/517 branch 3 times, most recently from 3981559 to e3c69ee Compare October 31, 2025 01:24
Comment thread include/infinicore/nn/embedding.hpp Outdated
Comment thread include/infinicore/nn/module.hpp
Comment thread src/infinicore/nn/embedding.cc Outdated
size_t embedding_dim,
std::optional<int64_t> padding_idx,
const Device &device)
: weight_(Parameter({num_embeddings, embedding_dim}, DataType::F32, device)),
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.

Embedding的初始化中,固定了权重参数weight_的数据类型是 DataType::F32, 如果safetensor中的数据类型是bf16能处理吗

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

加了datatype的入参

- Implement core modules: Linear, Embedding, RMSNorm
- Add PyTorch-like macros for module and parameter definition
  - INFINICORE_NN_MODULE for single module declaration
  - INFINICORE_NN_MODULE_VEC for module vectors
  - INFINICORE_NN_PARAMETER for parameter declaration
  - Corresponding INIT macros for initialization
- Implement hierarchical module system with dynamic path generation
- Add state_dict() and load_state_dict() support
- Refactor module design: protected registration methods, removed path_ member
- Add comprehensive test suite including TinyLlama integration
- All parameters are protected with public accessors
@PanZezhong1725 PanZezhong1725 linked an issue Oct 31, 2025 that may be closed by this pull request
@PanZezhong1725 PanZezhong1725 merged commit 0e01211 into main Oct 31, 2025
11 of 12 checks passed
@PanZezhong1725 PanZezhong1725 deleted the issue/517 branch October 31, 2025 08:08
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.

[DEV] InfiniCore 添加 nn::module c++接口

3 participants