Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
7d8ab5df
T
tensorflow
项目概览
xxadev
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7d8ab5df
编写于
4月 01, 2019
作者:
S
Sanjoy Das
提交者:
TensorFlower Gardener
4月 01, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass in the correct value for allow_resource_ops_in_called_functions
PiperOrigin-RevId: 241430735
上级
22413d6d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
1 deletion
+56
-1
tensorflow/compiler/jit/mark_for_compilation_pass.cc
tensorflow/compiler/jit/mark_for_compilation_pass.cc
+1
-1
tensorflow/compiler/jit/mark_for_compilation_pass_test.cc
tensorflow/compiler/jit/mark_for_compilation_pass_test.cc
+55
-0
未找到文件。
tensorflow/compiler/jit/mark_for_compilation_pass.cc
浏览文件 @
7d8ab5df
...
...
@@ -380,7 +380,7 @@ RecursiveCompilabilityChecker::OperationFilter CreateOperationFilter(
XlaOpRegistry
::
AutoclusteringPolicy
::
kAlways
;
RecursiveCompilabilityChecker
::
OperationFilter
op_filter
;
op_filter
.
allow_
non_resource_var_resource_op
s
=
op_filter
.
allow_
resource_ops_in_called_function
s
=
registration
.
compile_all_resource_ops
;
op_filter
.
allow_non_resource_var_resource_ops
=
registration
.
compile_all_resource_ops
;
...
...
tensorflow/compiler/jit/mark_for_compilation_pass_test.cc
浏览文件 @
7d8ab5df
...
...
@@ -277,6 +277,61 @@ TEST(XlaCompilationTest, FunctionCalls) {
EXPECT_TRUE
(
clusters
.
find
(
"E"
)
==
clusters
.
cend
());
}
TEST
(
XlaCompilationTest
,
CallXlaDeviceFuncWithResourceOp
)
{
FunctionDef
compilable
=
FunctionDefHelper
::
Define
(
"FnWithResourceOp"
,
{
"var:resource"
,
"val:float"
},
{
"retval:float"
},
{},
{{{
"assign_op"
},
"AssignVariableOp"
,
{
"var"
,
"val"
},
{{
"dtype"
,
DT_FLOAT
}}},
{{
"retval"
},
"Identity"
,
{
"val"
},
{{
"T"
,
DT_FLOAT
}},
{
"assign_op"
}}});
FunctionDefLibrary
flib
;
*
flib
.
add_function
()
=
compilable
;
FunctionLibraryDefinition
flib_def
(
OpRegistry
::
Global
(),
flib
);
std
::
unique_ptr
<
Graph
>
graph
(
new
Graph
(
&
flib_def
));
GraphDef
graphdef
;
{
GraphDefBuilder
builder
(
GraphDefBuilder
::
kFailImmediately
,
&
flib_def
);
Node
*
resource
=
ops
::
SourceOp
(
"VarHandleOp"
,
builder
.
opts
()
.
WithName
(
"varhandle"
)
.
WithAttr
(
"dtype"
,
DT_FLOAT
)
.
WithAttr
(
"shape"
,
TensorShape
({})));
Tensor
const_tensor
(
DT_FLOAT
,
TensorShape
({}));
const_tensor
.
scalar
<
float
>
()()
=
42.0
f
;
Node
*
value
=
ops
::
SourceOp
(
"Const"
,
builder
.
opts
()
.
WithName
(
"const"
)
.
WithAttr
(
"value"
,
const_tensor
)
.
WithAttr
(
"dtype"
,
DT_FLOAT
));
Node
*
call
=
ops
::
BinaryOp
(
"FnWithResourceOp"
,
resource
,
value
,
builder
.
opts
().
WithName
(
"A"
));
Node
*
tanh0
=
ops
::
UnaryOp
(
"Tanh"
,
call
,
builder
.
opts
().
WithName
(
"tanh0"
));
Node
*
tanh1
=
ops
::
UnaryOp
(
"Tanh"
,
tanh0
,
builder
.
opts
().
WithName
(
"tanh1"
));
ops
::
UnaryOp
(
"Tanh"
,
tanh1
,
builder
.
opts
().
WithName
(
"tanh2"
));
TF_EXPECT_OK
(
GraphDefBuilderToGraph
(
builder
,
graph
.
get
()));
}
string
xla_cpu_device
=
"/job:worker/replica:0/task:0/device:XLA_CPU:0"
;
testing
::
FindNodeByName
(
graph
.
get
(),
"A"
)
->
set_assigned_device_name
(
xla_cpu_device
);
testing
::
FindNodeByName
(
graph
.
get
(),
"tanh0"
)
->
set_assigned_device_name
(
xla_cpu_device
);
testing
::
FindNodeByName
(
graph
.
get
(),
"tanh1"
)
->
set_assigned_device_name
(
xla_cpu_device
);
testing
::
FindNodeByName
(
graph
.
get
(),
"tanh2"
)
->
set_assigned_device_name
(
xla_cpu_device
);
TF_ASSERT_OK
(
MarkForCompilationPassTestHelper
::
MarkForCompilation
(
&
graph
,
&
flib_def
));
auto
clusters
=
GetClusters
(
*
graph
);
EXPECT_NE
(
clusters
[
"A"
],
""
);
}
// Metadata-only operators such as Shape/Rank/Size may not be the root of a
// cluster. This is partially to work around b/26800664, and partially because
// we should probably prefer to compile metadata operators with their producers
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录