Skip to content

issue/896 - 为c++和python中的tensor添加打印函数#1121

Open
pengcheng888 wants to merge 1 commit intomainfrom
issue/896
Open

issue/896 - 为c++和python中的tensor添加打印函数#1121
pengcheng888 wants to merge 1 commit intomainfrom
issue/896

Conversation

@pengcheng888
Copy link
Copy Markdown
Collaborator

@pengcheng888 pengcheng888 commented Apr 7, 2026

目标版本
main

功能描述

打印的核心逻辑参考了 https://github.com/xtensor-stack/xtensor, 核心代码在io.cc文件中

c++和python中的tensor添加打印函数,可以全局临时配置一下参数:
(1) 触发省略的阈值:数据量过多时,显示部分数据;
(2) 每行显示字符数量:显示宽度合适,自动换行;
(3) 精度:设置显示的小数点位数;
(4) edgeitems: 省略显示时,设置显示的数据数量

c++的cout函数支持的类型: BOOL,I8,I16,I32,I64,U8,U16,U32,U64,BF16,F16,F32,F64
python的print函数支持的类型: BOOL,I8,I16,I32,I64,U8,BF16,F16,F32,F64

已测试平台:
nvidia moore metax iluvatar hygon

python代码std::cout测试:
临时修改后,自动恢复原始配置

Screenshot from 2026-01-21 13-51-53

全局修改后,配置生效
Screenshot from 2026-01-15 09-54-50

print不同的数据类型
Screenshot from 2026-01-15 09-53-30

c++代码print测试:
临时修改后,自动恢复原始配置
Screenshot from 2026-01-15 10-24-50

全局修改后,配置生效
Screenshot from 2026-01-15 10-24-33

cout不同的数据类型
Screenshot from 2026-01-15 10-24-19

在infinilm中使用:
Screenshot from 2026-01-21 15-35-19

@pengcheng888
Copy link
Copy Markdown
Collaborator Author

还需要在Infinilm中使用,进行更充分的验证后,再合并

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DEV] 提供显示美观的print函数,用于打印infinicore.Tensor数据

2 participants