Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
8
Issues
8
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
NiuTrans.Tensor
Commits
cadda317
Commit
cadda317
authored
Sep 20, 2019
by
xuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement the left-constant overloading and TtypeAs function
parent
36903fdb
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
0 行删除
+45
-0
source/tensor/XTensor.cpp
+30
-0
source/tensor/XTensor.h
+15
-0
没有找到文件。
source/tensor/XTensor.cpp
查看文件 @
cadda317
...
@@ -704,6 +704,12 @@ void XTensor::ReshapeMerged(const int i, const int j)
...
@@ -704,6 +704,12 @@ void XTensor::ReshapeMerged(const int i, const int j)
Reshape
(
order
-
1
,
dims
);
Reshape
(
order
-
1
,
dims
);
}
}
/* return a tensor that datatype is same as the special tensor */
XTensor
XTensor
::
TypeAs
(
const
XTensor
input
)
{
return
ConvertDataType
(
*
this
,
input
.
dataType
);
}
/* get the number of items in the data array */
/* get the number of items in the data array */
int
XTensor
::
GetSize
()
const
int
XTensor
::
GetSize
()
const
{
{
...
@@ -3047,4 +3053,28 @@ void DelTensorBuf(XTensor * tensor)
...
@@ -3047,4 +3053,28 @@ void DelTensorBuf(XTensor * tensor)
delete
tensor
;
delete
tensor
;
}
}
/* overloading of the plus-sign */
XTensor
operator
+
(
const
DTYPE
shift
,
const
XTensor
&
tensor
)
{
return
ScaleAndShift
(
tensor
,
1
,
shift
);
}
/* overloading of the minus-sign */
XTensor
operator
-
(
const
DTYPE
shift
,
const
XTensor
&
tensor
)
{
return
ScaleAndShift
(
tensor
,
1
,
-
shift
);
}
/* overloading of the multiply-sign */
XTensor
operator
*
(
const
DTYPE
scale
,
const
XTensor
&
tensor
)
{
return
ScaleAndShift
(
tensor
,
scale
,
0
);
}
/* overloading of the division-sign */
XTensor
operator
/
(
const
DTYPE
scale
,
const
XTensor
&
tensor
)
{
return
ScaleAndShift
(
tensor
,
(
DTYPE
)
1
/
scale
,
0
);
}
}
/* end of the nts (NiuTrans.Tensor) namespace */
}
/* end of the nts (NiuTrans.Tensor) namespace */
source/tensor/XTensor.h
查看文件 @
cadda317
...
@@ -283,6 +283,9 @@ public:
...
@@ -283,6 +283,9 @@ public:
/* reshape the tensor by merging two consecutive dimensions */
/* reshape the tensor by merging two consecutive dimensions */
void
ReshapeMerged
(
const
int
i
,
const
int
j
=
-
1
);
void
ReshapeMerged
(
const
int
i
,
const
int
j
=
-
1
);
/* return a tensor that datatype is same as the special tensor */
XTensor
TypeAs
(
const
XTensor
input
);
/* get the number of items in the data array */
/* get the number of items in the data array */
int
GetSize
()
const
;
int
GetSize
()
const
;
...
@@ -599,6 +602,18 @@ void DelTensor(XTensor * tensor);
...
@@ -599,6 +602,18 @@ void DelTensor(XTensor * tensor);
/* free the data space of a given tensor (on the buffer) */
/* free the data space of a given tensor (on the buffer) */
void
DelTensorBuf
(
XTensor
*
tensor
);
void
DelTensorBuf
(
XTensor
*
tensor
);
/* overloading of the plus-sign */
XTensor
operator
+
(
const
DTYPE
shift
,
const
XTensor
&
tensor
);
/* overloading of the minus-sign */
XTensor
operator
-
(
const
DTYPE
shift
,
const
XTensor
&
tensor
);
/* overloading of the multiply-sign */
XTensor
operator
*
(
const
DTYPE
scale
,
const
XTensor
&
tensor
);
/* overloading of the division-sign */
XTensor
operator
/
(
const
DTYPE
scale
,
const
XTensor
&
tensor
);
}
/* end of the nts (NiuTrans.Tensor) namespace */
}
/* end of the nts (NiuTrans.Tensor) namespace */
#endif
#endif
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论