Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
Emmay
NiuTrans.Tensor
Commits
b3c2cf56
Commit
b3c2cf56
authored
Mar 27, 2019
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding "name" into XTensor. Now we can search for a node in the network by its "name".
parent
9ac1028a
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
60 行增加
和
0 行删除
+60
-0
source/network/XNet.cpp
+12
-0
source/network/XNet.h
+4
-0
source/tensor/XLink.cpp
+25
-0
source/tensor/XLink.h
+4
-0
source/tensor/XTensor.cpp
+8
-0
source/tensor/XTensor.h
+7
-0
没有找到文件。
source/network/XNet.cpp
查看文件 @
b3c2cf56
...
...
@@ -458,4 +458,15 @@ void XNet::ShowNetwork(FILE * file, XTensor * node)
}
}
/*
search for a node in a top-down manner by its name
>> top - the top most node
<< return - the node we found
*/
XTensor
*
XNet
::
SearchNode
(
XTensor
*
top
,
const
char
*
name
)
{
return
XLink
::
SearchNode
(
top
,
name
);
}
}
\ No newline at end of file
source/network/XNet.h
查看文件 @
b3c2cf56
...
...
@@ -111,6 +111,10 @@ struct XNet
/* show network topology */
void
ShowNetwork
(
FILE
*
file
,
XTensor
*
node
);
/* search a node in a top-down manner by its name */
static
XTensor
*
SearchNode
(
XTensor
*
top
,
const
char
*
name
);
};
/* we make a unique id for every tensor */
...
...
source/tensor/XLink.cpp
查看文件 @
b3c2cf56
...
...
@@ -528,6 +528,8 @@ void XLink::Replace(const XTensor * oldOne, XTensor * newOne)
CheckNTErrors
(
hit
,
"No proper node found in parent.income edge!"
);
}
}
strcpy
(
newOne
->
name
,
oldOne
->
name
);
}
/*
...
...
@@ -655,6 +657,29 @@ void XLink::ShowNode(FILE * file, XTensor * node)
fprintf
(
stderr
,
"
\n
"
);
}
/*
search for a node in a top-down manner by its name
>> top - the top most node
<< return - the node we found
*/
XTensor
*
XLink
::
SearchNode
(
XTensor
*
top
,
const
char
*
name
)
{
if
(
!
strcmp
(
top
->
name
,
name
))
return
top
;
XLink
&
incoming
=
top
->
income
;
for
(
int
i
=
0
;
i
<
incoming
.
tailNum
;
i
++
){
XTensor
*
child
=
incoming
.
tails
[
i
];
XTensor
*
hit
=
SearchNode
(
child
,
name
);
if
(
hit
!=
NULL
)
return
hit
;
}
return
NULL
;
}
}
// namespace nts(NiuTrans.Tensor)
source/tensor/XLink.h
查看文件 @
b3c2cf56
...
...
@@ -185,6 +185,10 @@ struct XLink
/* show a node */
static
void
ShowNode
(
FILE
*
file
,
XTensor
*
node
);
/* search a node in a top-down manner by its name */
static
XTensor
*
SearchNode
(
XTensor
*
top
,
const
char
*
name
);
};
}
// namespace nts(NiuTrans.Tensor)
...
...
source/tensor/XTensor.cpp
查看文件 @
b3c2cf56
...
...
@@ -251,9 +251,16 @@ XTensor::~XTensor()
delete
grad
;
}
/* set the name of the tensor */
void
XTensor
::
SetName
(
const
char
*
myName
)
{
strcpy
(
name
,
myName
);
}
/* initialize member variables */
void
XTensor
::
Init
()
{
name
[
0
]
=
'\0'
;
id
=
-
1
;
mem
=
NULL
;
signature
=
0
;
...
...
@@ -306,6 +313,7 @@ Note that we do not copy data array here
*/
void
XTensor
::
ShallowCopy
(
const
XTensor
&
tensor
)
{
strcpy
(
name
,
tensor
.
name
);
order
=
tensor
.
order
;
memcpy
(
dimSize
,
tensor
.
dimSize
,
sizeof
(
int
)
*
MAX_TENSOR_DIM_NUM
);
memcpy
(
dimSizeRDI
,
tensor
.
dimSizeRDI
,
sizeof
(
int
)
*
MAX_TENSOR_DIM_NUM
);
...
...
source/tensor/XTensor.h
查看文件 @
b3c2cf56
...
...
@@ -52,6 +52,7 @@ struct XLink;
#define MIN_TENSOR_MERGE_NUM 0
#define MIN_TENSOR_MERGE_LIST_NUM 1024
#define MIN_TENSOR_CAT_NUM 8
#define MAX_TENSOR_NAME_SIZE 32
/* computation flags */
#define UNSAFE_BUT_FAST_MEM
...
...
@@ -61,6 +62,9 @@ struct XLink;
struct
XTensor
{
public
:
/* name */
char
name
[
MAX_TENSOR_NAME_SIZE
];
/* id */
int
id
;
...
...
@@ -197,6 +201,9 @@ public:
/* de-constructor */
~
XTensor
();
/* set the name of the tensor */
void
SetName
(
const
char
*
myName
);
/* initialize member variables */
void
Init
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论