Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
d04515aa
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 接近 3 年
通知
13
Star
2733
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oneflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d04515aa
编写于
7月 21, 2018
作者:
X
Xinqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
assert that the oprant types of binary-expression-lazy-blob core op must be identical
Former-commit-id: 8518e1bdb3bf3bf90c5da94a708243cb0808c637
上级
b96550dd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
26 deletion
+23
-26
oneflow/core/register/lazy_blob.h
oneflow/core/register/lazy_blob.h
+23
-26
未找到文件。
oneflow/core/register/lazy_blob.h
浏览文件 @
d04515aa
...
...
@@ -193,8 +193,8 @@ class VarLazyBlob final : public LazyBlobIf<VarLazyBlob<T>> {
template
<
template
<
typename
>
class
CoreFunc
,
typename
XT
>
class
UnaryExpresionLazyBlob
final
:
public
LazyBlobIf
<
UnaryExpresionLazyBlob
<
CoreFunc
,
XT
>>
{
public:
using
XD
T
=
typename
XT
::
dtype
;
typedef
decltype
(
CoreFunc
<
XDT
>::
Invoke
(
*
(
const
XD
T
*
)
nullptr
))
dtype
;
using
T
=
typename
XT
::
dtype
;
typedef
decltype
(
CoreFunc
<
T
>::
Invoke
(
*
(
const
T
*
)
nullptr
))
dtype
;
OF_DISALLOW_COPY_AND_MOVE
(
UnaryExpresionLazyBlob
);
explicit
UnaryExpresionLazyBlob
(
const
XT
&
x
)
...
...
@@ -202,31 +202,32 @@ class UnaryExpresionLazyBlob final : public LazyBlobIf<UnaryExpresionLazyBlob<Co
GetDataType
<
dtype
>::
value
),
x_
(
x
)
{}
inline
dtype
operator
()(
int64_t
dim0
)
const
{
return
CoreFunc
<
XD
T
>::
Invoke
(
x_
(
dim0
));
}
inline
dtype
operator
()(
int64_t
dim0
)
const
{
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
)
const
{
return
CoreFunc
<
XD
T
>::
Invoke
(
x_
(
dim0
,
dim1
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
,
int64_t
dim2
)
const
{
return
CoreFunc
<
XD
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
,
int64_t
dim2
,
int64_t
dim3
)
const
{
return
CoreFunc
<
XD
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
,
int64_t
dim2
,
int64_t
dim3
,
int64_t
dim4
)
const
{
return
CoreFunc
<
XD
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
,
dim4
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
,
dim4
));
}
private:
const
XT
&
x_
;
};
template
<
template
<
typename
,
typename
>
class
CoreFunc
,
typename
XT
,
typename
YT
=
XT
>
template
<
template
<
typename
>
class
CoreFunc
,
typename
XT
,
typename
YT
=
XT
,
typename
=
typename
std
::
enable_if
<
std
::
is_same
<
typename
XT
::
dtype
,
typename
YT
::
dtype
>
::
value
>::
type
>
class
BinaryExpresionLazyBlob
final
:
public
LazyBlobIf
<
BinaryExpresionLazyBlob
<
CoreFunc
,
XT
,
YT
>>
{
public:
using
XDT
=
typename
XT
::
dtype
;
using
YDT
=
typename
YT
::
dtype
;
typedef
decltype
(
CoreFunc
<
XDT
,
YDT
>::
Invoke
(
*
(
const
XDT
*
)
nullptr
,
*
(
const
YDT
*
)
nullptr
))
dtype
;
using
T
=
typename
XT
::
dtype
;
typedef
decltype
(
CoreFunc
<
T
>::
Invoke
(
*
(
const
T
*
)
nullptr
,
*
(
const
T
*
)
nullptr
))
dtype
;
OF_DISALLOW_COPY_AND_MOVE
(
BinaryExpresionLazyBlob
);
BinaryExpresionLazyBlob
(
const
XT
&
x
,
const
YT
&
y
)
...
...
@@ -237,22 +238,19 @@ class BinaryExpresionLazyBlob final : public LazyBlobIf<BinaryExpresionLazyBlob<
CHECK
(
x
.
shape
()
==
y
.
shape
());
}
inline
dtype
operator
()(
int64_t
dim0
)
const
{
return
CoreFunc
<
XDT
,
YDT
>::
Invoke
(
x_
(
dim0
),
y_
(
dim0
));
}
inline
dtype
operator
()(
int64_t
dim0
)
const
{
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
),
y_
(
dim0
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
)
const
{
return
CoreFunc
<
XDT
,
YD
T
>::
Invoke
(
x_
(
dim0
,
dim1
),
y_
(
dim0
,
dim1
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
),
y_
(
dim0
,
dim1
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
,
int64_t
dim2
)
const
{
return
CoreFunc
<
XDT
,
YD
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
),
y_
(
dim0
,
dim1
,
dim2
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
),
y_
(
dim0
,
dim1
,
dim2
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
,
int64_t
dim2
,
int64_t
dim3
)
const
{
return
CoreFunc
<
XDT
,
YD
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
),
y_
(
dim0
,
dim1
,
dim2
,
dim3
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
),
y_
(
dim0
,
dim1
,
dim2
,
dim3
));
}
inline
dtype
operator
()(
int64_t
dim0
,
int64_t
dim1
,
int64_t
dim2
,
int64_t
dim3
,
int64_t
dim4
)
const
{
return
CoreFunc
<
XDT
,
YDT
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
,
dim4
),
y_
(
dim0
,
dim1
,
dim2
,
dim3
,
dim4
));
return
CoreFunc
<
T
>::
Invoke
(
x_
(
dim0
,
dim1
,
dim2
,
dim3
,
dim4
),
y_
(
dim0
,
dim1
,
dim2
,
dim3
,
dim4
));
}
private:
...
...
@@ -263,8 +261,7 @@ class BinaryExpresionLazyBlob final : public LazyBlobIf<BinaryExpresionLazyBlob<
template
<
typename
XT
>
class
BroadcastLazyBlob
final
:
public
LazyBlobIf
<
BroadcastLazyBlob
<
XT
>>
{
public:
using
XDT
=
typename
XT
::
dtype
;
typedef
XDT
dtype
;
typedef
typename
XT
::
dtype
dtype
;
OF_DISALLOW_MOVE
(
BroadcastLazyBlob
);
BroadcastLazyBlob
(
const
BroadcastLazyBlob
<
XT
>&
)
=
default
;
...
...
@@ -355,10 +352,10 @@ class LazyBlobVarBuilder final {
OF_PP_MAKE_TUPLE_SEQ(LogicalAnd, &&, bool) \
OF_PP_MAKE_TUPLE_SEQ(LogicalOr, &&, bool)
#define DECLARE_LAZY_BLOB_BINARY_CORE(name, op, ret_type)
\
template<typename T
, typename YDT = T>
\
struct LazyBlobCore##name final {
\
static inline ret_type Invoke(const T x, const
YD
T y) { return x op y; } \
#define DECLARE_LAZY_BLOB_BINARY_CORE(name, op, ret_type) \
template<typename T
>
\
struct LazyBlobCore##name final { \
static inline ret_type Invoke(const T x, const T y) { return x op y; } \
};
OF_PP_FOR_EACH_TUPLE
(
DECLARE_LAZY_BLOB_BINARY_CORE
,
LAZY_BLOB_BINARY_CORE_OP_FUNC_SEQ
);
...
...
@@ -373,7 +370,7 @@ OF_PP_FOR_EACH_TUPLE(DECLARE_LAZY_BLOB_BINARY_CORE, LAZY_BLOB_BINARY_CORE_OP_FUN
};
OF_PP_FOR_EACH_TUPLE
(
DECLARE_LAZY_BLOB_UNARY_CORE
,
LAZY_BLOB_UNARY_CORE_OP_FUNC_SEQ
);
template
<
template
<
typename
,
typename
>
class
LazyBlobCoreFunc
,
typename
XT
,
typename
YT
=
XT
>
template
<
template
<
typename
>
class
LazyBlobCoreFunc
,
typename
XT
,
typename
YT
=
XT
>
typename
std
::
enable_if
<
std
::
is_base_of
<
LazyBlobNode
,
XT
>::
value
&&
std
::
is_base_of
<
LazyBlobNode
,
YT
>::
value
,
BinaryExpresionLazyBlob
<
LazyBlobCoreFunc
,
XT
,
YT
>>::
type
&
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录