Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
33f512e6
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 2 年多
通知
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
33f512e6
编写于
7月 19, 2020
作者:
qq_22305325
提交者:
GitHub
7月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
replace old api of fix_placement (#3234)
上级
4bfec0d9
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
72 addition
and
72 deletion
+72
-72
oneflow/python/eager/op_executor.py
oneflow/python/eager/op_executor.py
+1
-1
oneflow/python/framework/input_blob_def.py
oneflow/python/framework/input_blob_def.py
+1
-1
oneflow/python/ops/assign_op.py
oneflow/python/ops/assign_op.py
+1
-1
oneflow/python/ops/two_stage_reduce.py
oneflow/python/ops/two_stage_reduce.py
+1
-1
oneflow/python/ops/watch.py
oneflow/python/ops/watch.py
+1
-1
oneflow/python/test/customized/test_source.py
oneflow/python/test/customized/test_source.py
+1
-1
oneflow/python/test/ops/test_2d_gpu_variable.py
oneflow/python/test/ops/test_2d_gpu_variable.py
+1
-1
oneflow/python/test/ops/test_TestDynamicSource.py
oneflow/python/test/ops/test_TestDynamicSource.py
+1
-1
oneflow/python/test/ops/test_TestRandomSource.py
oneflow/python/test/ops/test_TestRandomSource.py
+1
-1
oneflow/python/test/ops/test_TestSource.py
oneflow/python/test/ops/test_TestSource.py
+1
-1
oneflow/python/test/ops/test_TestSourceMultiGpuFixedOutNum.py
...low/python/test/ops/test_TestSourceMultiGpuFixedOutNum.py
+1
-1
oneflow/python/test/ops/test_argmax.py
oneflow/python/test/ops/test_argmax.py
+1
-1
oneflow/python/test/ops/test_argsort.py
oneflow/python/test/ops/test_argsort.py
+1
-1
oneflow/python/test/ops/test_assign.py
oneflow/python/test/ops/test_assign.py
+1
-1
oneflow/python/test/ops/test_boxing_v2.py
oneflow/python/test/ops/test_boxing_v2.py
+14
-14
oneflow/python/test/ops/test_broadcast_like.py
oneflow/python/test/ops/test_broadcast_like.py
+1
-1
oneflow/python/test/ops/test_broadcast_maximum.py
oneflow/python/test/ops/test_broadcast_maximum.py
+1
-1
oneflow/python/test/ops/test_broadcast_minimum.py
oneflow/python/test/ops/test_broadcast_minimum.py
+1
-1
oneflow/python/test/ops/test_cast.py
oneflow/python/test/ops/test_cast.py
+1
-1
oneflow/python/test/ops/test_copy_comm_net_pass_empty.py
oneflow/python/test/ops/test_copy_comm_net_pass_empty.py
+11
-11
oneflow/python/test/ops/test_dynamic_binary.py
oneflow/python/test/ops/test_dynamic_binary.py
+4
-4
oneflow/python/test/ops/test_expand_dims.py
oneflow/python/test/ops/test_expand_dims.py
+1
-1
oneflow/python/test/ops/test_function_config.py
oneflow/python/test/ops/test_function_config.py
+2
-2
oneflow/python/test/ops/test_gather_model_parallel.py
oneflow/python/test/ops/test_gather_model_parallel.py
+1
-1
oneflow/python/test/ops/test_indexed_slices_reduce_sum.py
oneflow/python/test/ops/test_indexed_slices_reduce_sum.py
+1
-1
oneflow/python/test/ops/test_keep_header_only_cpu.py
oneflow/python/test/ops/test_keep_header_only_cpu.py
+1
-1
oneflow/python/test/ops/test_multiply.py
oneflow/python/test/ops/test_multiply.py
+1
-1
oneflow/python/test/ops/test_one_hot.py
oneflow/python/test/ops/test_one_hot.py
+1
-1
oneflow/python/test/ops/test_prelu.py
oneflow/python/test/ops/test_prelu.py
+1
-1
oneflow/python/test/ops/test_shuffle.py
oneflow/python/test/ops/test_shuffle.py
+2
-2
oneflow/python/test/ops/test_smooth_l1_loss.py
oneflow/python/test/ops/test_smooth_l1_loss.py
+1
-1
oneflow/python/test/ops/test_sort.py
oneflow/python/test/ops/test_sort.py
+1
-1
oneflow/python/test/ops/test_square_sum.py
oneflow/python/test/ops/test_square_sum.py
+1
-1
oneflow/python/test/ops/test_squeeze.py
oneflow/python/test/ops/test_squeeze.py
+1
-1
oneflow/python/test/ops/test_sync_dynamic_resize.py
oneflow/python/test/ops/test_sync_dynamic_resize.py
+1
-1
oneflow/python/test/ops/test_top_k.py
oneflow/python/test/ops/test_top_k.py
+1
-1
oneflow/python/test/ops/test_two_stage_reduce.py
oneflow/python/test/ops/test_two_stage_reduce.py
+2
-2
oneflow/python/test/ops/test_unary_elementwise_ops.py
oneflow/python/test/ops/test_unary_elementwise_ops.py
+1
-1
oneflow/python/test/ops/test_unique.py
oneflow/python/test/ops/test_unique.py
+1
-1
oneflow/python/test/ops/test_unsorted_batch_segment_sum.py
oneflow/python/test/ops/test_unsorted_batch_segment_sum.py
+1
-1
oneflow/python/test/ops/test_unsorted_segment_sum.py
oneflow/python/test/ops/test_unsorted_segment_sum.py
+2
-2
oneflow/python/test/ops/test_unsorted_segment_sum_model_parallel.py
...thon/test/ops/test_unsorted_segment_sum_model_parallel.py
+1
-1
未找到文件。
oneflow/python/eager/op_executor.py
浏览文件 @
33f512e6
...
...
@@ -104,7 +104,7 @@ def _MakeEagerLogicalBlob(op_attribute, obn, blob_register):
def
EagerInitVariableBlob
(
var_op_conf
,
var_blob
):
with
oneflow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
oneflow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
_Assign
(
var_blob
.
blob_object
,
_ModelInit
(
var_op_conf
))
...
...
oneflow/python/framework/input_blob_def.py
浏览文件 @
33f512e6
...
...
@@ -161,7 +161,7 @@ class FixedTensorDef(ArgBlobDef):
else
:
device_tag
=
"cpu"
device_ids
=
"0:0"
with
oneflow
.
fixed_
placement
(
device_tag
,
device_ids
):
with
oneflow
.
scope
.
placement
(
device_tag
,
device_ids
):
return
compile_context
.
CurJobAddConsistentOp
(
op_conf
)
def
SetBatchAxisAndSplitAxis
(
...
...
oneflow/python/ops/assign_op.py
浏览文件 @
33f512e6
...
...
@@ -55,7 +55,7 @@ def lazy_system_assign(ref, value, validate_shape=None, use_locking=None, name=N
device_tag
,
machine_device_ids
=
parallel_conf_util
.
GetDeviceTagAndMachineDeviceIds
(
ref
.
parallel_conf
)
with
oneflow
.
fixed_
placement
(
device_tag
,
machine_device_ids
):
with
oneflow
.
scope
.
placement
(
device_tag
,
machine_device_ids
):
interpret_util
.
Forward
(
op_conf
)
return
ref
...
...
oneflow/python/ops/two_stage_reduce.py
浏览文件 @
33f512e6
...
...
@@ -63,7 +63,7 @@ def two_stage_reduce(x, axis=None, keepdims=False, op_type_name=None, name=None)
device_ids
,
)
in
current_placement_scope
.
machine_id2device_id_list
.
items
():
for
device_id
in
device_ids
:
with
flow
.
fixed_
placement
(
with
flow
.
scope
.
placement
(
device_tag
,
str
(
machine_id
)
+
":"
+
str
(
device_id
)
):
device_stage_out
,
device_stage_count
=
reduce_device_stage
(
...
...
oneflow/python/ops/watch.py
浏览文件 @
33f512e6
...
...
@@ -51,7 +51,7 @@ def LazyWatch(blob_watched, handler_or_prompt=None):
tag_and_dev_ids
=
parallel_conf_util
.
GetDeviceTagAndMachineDeviceIds
(
blob_watched
.
parallel_conf
)
with
oneflow
.
fixed_
placement
(
*
tag_and_dev_ids
):
with
oneflow
.
scope
.
placement
(
*
tag_and_dev_ids
):
compile_context
.
CurJobAddOp
(
op_conf
)
watcher_util
.
BindUuidAndHandler
(
handler_uuid
,
blob_watched
,
handler
)
elif
isinstance
(
blob_watched
,
MirroredBlob
):
...
...
oneflow/python/test/customized/test_source.py
浏览文件 @
33f512e6
...
...
@@ -9,7 +9,7 @@ func_config.default_data_type(flow.float)
def
my_test_source
(
name
):
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
return
(
flow
.
user_op_builder
(
name
)
.
Op
(
"TestSource"
)
...
...
oneflow/python/test/ops/test_2d_gpu_variable.py
浏览文件 @
33f512e6
...
...
@@ -11,7 +11,7 @@ def test_2d_gpu_variable(test_case):
@
flow
.
global_function
(
function_config
)
def
Foo
():
with
flow
.
fixed_
placement
(
"gpu"
,
device_name
):
with
flow
.
scope
.
placement
(
"gpu"
,
device_name
):
w
=
flow
.
get_variable
(
"w"
,
shape
=
(
10
,),
...
...
oneflow/python/test/ops/test_TestDynamicSource.py
浏览文件 @
33f512e6
...
...
@@ -20,7 +20,7 @@ def test_test_dynamic_source(test_case):
@
flow
.
global_function
(
func_config
)
def
TestSourceJob
():
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
ret
=
my_test_source
(
"my_cc_test_source_op"
)
return
ret
...
...
oneflow/python/test/ops/test_TestRandomSource.py
浏览文件 @
33f512e6
...
...
@@ -21,7 +21,7 @@ def test_testsource(test_case):
@
flow
.
global_function
(
func_config
)
def
TestSourceJob
():
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
ret
=
my_test_source
(
"my_cc_test_source_op"
,
0
)
return
ret
...
...
oneflow/python/test/ops/test_TestSource.py
浏览文件 @
33f512e6
...
...
@@ -20,7 +20,7 @@ def test_testsource(test_case):
@
flow
.
global_function
(
func_config
)
def
TestSourceJob
():
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
ret
=
my_test_source
(
"my_cc_test_source_op"
)
# print("cons_test_source_batch_axis", ret.batch_axis)
test_case
.
assertTrue
(
ret
.
batch_axis
is
not
None
and
ret
.
batch_axis
==
0
)
...
...
oneflow/python/test/ops/test_TestSourceMultiGpuFixedOutNum.py
浏览文件 @
33f512e6
...
...
@@ -21,7 +21,7 @@ def test_testsource_2_gpu(test_case):
@
flow
.
global_function
(
func_config
)
def
TestSourceJob
():
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0-1"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0-1"
):
ret
=
my_test_source
(
"my_cc_test_source_op"
,
10
)
# print("cons_test_source_batch_axis", ret.batch_axis)
test_case
.
assertTrue
(
ret
.
batch_axis
is
not
None
and
ret
.
batch_axis
==
0
)
...
...
oneflow/python/test/ops/test_argmax.py
浏览文件 @
33f512e6
...
...
@@ -24,7 +24,7 @@ def compare_with_tensorflow(device_type, in_shape, data_type):
dtype
=
type_name_to_flow_type
[
data_type
],
)
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
math
.
argmax
(
input
)
input
=
(
np
.
random
.
random
(
in_shape
)
*
100
).
astype
(
type_name_to_np_type
[
data_type
])
...
...
oneflow/python/test/ops/test_argsort.py
浏览文件 @
33f512e6
...
...
@@ -24,7 +24,7 @@ def compare_with_tensorflow(device_type, in_shape, direction, data_type):
dtype
=
type_name_to_flow_type
[
data_type
],
)
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
argsort
(
input
,
direction
)
input
=
(
np
.
random
.
random
(
in_shape
)
*
100
).
astype
(
type_name_to_np_type
[
data_type
])
...
...
oneflow/python/test/ops/test_assign.py
浏览文件 @
33f512e6
...
...
@@ -27,7 +27,7 @@ def _of_assign_and_relu(value, dtype, device_type):
flow
.
config
.
cpu_device_num
(
1
)
func_config
=
flow
.
FunctionConfig
()
func_config
.
default_data_type
(
dtype
)
func_config
.
default_placement_scope
(
flow
.
fixed_
placement
(
device_type
,
"0:0"
))
func_config
.
default_placement_scope
(
flow
.
scope
.
placement
(
device_type
,
"0:0"
))
@
flow
.
global_function
(
func_config
)
def
assign_fn
(
value_def
=
flow
.
FixedTensorDef
(
value
.
shape
,
dtype
=
dtype
)):
...
...
oneflow/python/test/ops/test_boxing_v2.py
浏览文件 @
33f512e6
...
...
@@ -22,9 +22,9 @@ def _test_split_to_split(
@
flow
.
global_function
(
func_config
)
def
split_to_split_job
(
x
=
flow
.
FixedTensorDef
((
96
,
96
))):
with
flow
.
fixed_
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
with
flow
.
scope
.
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
src
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
src_axis
)))
with
flow
.
fixed_
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
with
flow
.
scope
.
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
dst
=
flow
.
identity
(
src
.
with_distribute
(
flow
.
distribute
.
split
(
dst_axis
)))
return
dst
...
...
@@ -61,9 +61,9 @@ def _test_split_to_broadcast(
@
flow
.
global_function
(
func_config
)
def
split_to_broadcast_job
(
x
=
flow
.
FixedTensorDef
((
96
,
96
))):
with
flow
.
fixed_
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
with
flow
.
scope
.
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
src
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
src_axis
)))
with
flow
.
fixed_
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
with
flow
.
scope
.
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
dst
=
flow
.
identity
(
src
.
with_distribute
(
flow
.
distribute
.
broadcast
()))
return
dst
...
...
@@ -99,9 +99,9 @@ def _test_broadcast_to_split(
@
flow
.
global_function
(
func_config
)
def
broadcast_to_split_job
(
x
=
flow
.
FixedTensorDef
((
96
,
96
))):
with
flow
.
fixed_
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
with
flow
.
scope
.
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
src
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
broadcast
()))
with
flow
.
fixed_
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
with
flow
.
scope
.
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
dst
=
flow
.
identity
(
src
.
with_distribute
(
flow
.
distribute
.
split
(
dst_axis
)))
return
dst
...
...
@@ -137,10 +137,10 @@ def _test_partial_sum_to_split(
@
flow
.
global_function
(
func_config
)
def
partial_sum_to_split_job
(
x
=
flow
.
FixedTensorDef
((
96
,
96
,
96
))):
with
flow
.
fixed_
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
with
flow
.
scope
.
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
src
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
0
)))
src
=
flow
.
math
.
reduce_sum
(
src
,
axis
=
0
)
with
flow
.
fixed_
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
with
flow
.
scope
.
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
dst
=
flow
.
identity
(
src
.
with_distribute
(
flow
.
distribute
.
split
(
dst_axis
)))
return
dst
...
...
@@ -171,10 +171,10 @@ def _test_partial_sum_to_broadcast(
@
flow
.
global_function
(
func_config
)
def
partial_sum_to_broadcast_job
(
x
=
flow
.
FixedTensorDef
((
96
,
96
,
96
))):
with
flow
.
fixed_
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
with
flow
.
scope
.
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
src
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
0
)))
src
=
flow
.
math
.
reduce_sum
(
src
,
axis
=
0
)
with
flow
.
fixed_
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
with
flow
.
scope
.
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
dst
=
flow
.
identity
(
src
.
with_distribute
(
flow
.
distribute
.
broadcast
()))
return
dst
...
...
@@ -204,9 +204,9 @@ def _test_broadcast_to_broadcast(
@
flow
.
global_function
(
func_config
)
def
broadcast_to_broadcast_job
(
x
=
flow
.
FixedTensorDef
((
96
,
96
,
96
))):
with
flow
.
fixed_
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
with
flow
.
scope
.
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
src
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
broadcast
()))
with
flow
.
fixed_
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
with
flow
.
scope
.
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
dst
=
flow
.
identity
(
src
.
with_distribute
(
flow
.
distribute
.
broadcast
()))
return
dst
...
...
@@ -237,12 +237,12 @@ def _test_multi_lbi(
@
flow
.
global_function
(
func_config
)
def
multi_lbi_job
(
x
=
flow
.
FixedTensorDef
((
96
,
96
,
96
))):
with
flow
.
fixed_
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
with
flow
.
scope
.
placement
(
src_device_type
,
"0:0-"
+
str
(
src_device_num
-
1
)):
src_s0
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
0
)))
src_s1
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
1
)))
src_b
=
flow
.
identity
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
1
)))
(
t0_0
,
t0_1
,
t0_2
)
=
flow
.
identity_n
((
src_s0
,
src_s1
,
src_b
))
with
flow
.
fixed_
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
with
flow
.
scope
.
placement
(
dst_device_type
,
"0:0-"
+
str
(
dst_device_num
-
1
)):
t0_0
=
t0_0
.
with_distribute
(
flow
.
distribute
.
split
(
1
))
t0_1
=
t0_1
.
with_distribute
(
flow
.
distribute
.
broadcast
())
t0_2
=
t0_2
.
with_distribute
(
flow
.
distribute
.
split
(
1
))
...
...
oneflow/python/test/ops/test_broadcast_like.py
浏览文件 @
33f512e6
...
...
@@ -21,7 +21,7 @@ def compare_broadcast_like_with_tf(
x
=
flow
.
FixedTensorDef
(
shape
=
input_shape
,
dtype
=
data_type_util
.
kFloat
),
y
=
flow
.
FixedTensorDef
(
shape
=
like_shape
,
dtype
=
data_type_util
.
kFloat
),
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
broadcast_like
(
x
,
y
,
broadcast_axes
=
broadcast_axes
)
x
=
np
.
random
.
rand
(
*
input_shape
).
astype
(
np
.
float32
)
...
...
oneflow/python/test/ops/test_broadcast_maximum.py
浏览文件 @
33f512e6
...
...
@@ -15,7 +15,7 @@ def _run_test(test_case, a, b, dtype, device):
a
=
flow
.
FixedTensorDef
(
a
.
shape
,
dtype
=
dtype
),
b
=
flow
.
FixedTensorDef
(
b
.
shape
,
dtype
=
dtype
),
):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
return
flow
.
math
.
maximum
(
a
,
b
)
out
=
BroadcastMaximum
(
a
,
b
).
get
()
...
...
oneflow/python/test/ops/test_broadcast_minimum.py
浏览文件 @
33f512e6
...
...
@@ -15,7 +15,7 @@ def _run_test(test_case, a, b, dtype, device):
a
=
flow
.
FixedTensorDef
(
a
.
shape
,
dtype
=
dtype
),
b
=
flow
.
FixedTensorDef
(
b
.
shape
,
dtype
=
dtype
),
):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
return
flow
.
math
.
minimum
(
a
,
b
)
out
=
BroadcastMinimum
(
a
,
b
).
get
()
...
...
oneflow/python/test/ops/test_cast.py
浏览文件 @
33f512e6
...
...
@@ -20,7 +20,7 @@ def cast_forward_compare_with_tensorflow(test_cast, device_type, input_shape, dt
shape
=
input_shape
,
dtype
=
type_name_to_flow_type
[
dtype
]
)
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
cast
(
input_def
,
dtype
=
type_name_to_flow_type
[
dtype
])
input
=
np
.
random
.
rand
(
*
input_shape
).
astype
(
type_name_to_np_type
[
dtype
])
...
...
oneflow/python/test/ops/test_copy_comm_net_pass_empty.py
浏览文件 @
33f512e6
...
...
@@ -23,11 +23,11 @@ def test_multi_node_comm_net(test_case):
@
flow
.
global_function
(
func_config
)
def
ReluJob
(
x
=
flow
.
FixedTensorDef
((
10
,
2
))):
with
flow
.
fixed_
placement
(
"gpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"gpu"
,
"0:0"
):
out0
=
ccrelu
(
x
,
"my_op_0_0"
)
with
flow
.
fixed_
placement
(
"gpu"
,
"1:0"
):
with
flow
.
scope
.
placement
(
"gpu"
,
"1:0"
):
out1
=
ccrelu
(
out0
,
"my_op_1_0"
)
with
flow
.
fixed_
placement
(
"gpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"gpu"
,
"0:0"
):
out2
=
ccrelu
(
out1
,
"my_op_print"
)
return
out2
...
...
@@ -52,18 +52,18 @@ def test_multi_node_comm_net(test_case):
def
test_multi_node_comm_net_dynamic
(
test_case
):
func_config
=
flow
.
FunctionConfig
()
func_config
.
default_distribute_strategy
(
flow
.
scope
.
mirrored_view
())
func_config
.
default_placement_scope
(
flow
.
fixed_
placement
(
"gpu"
,
"0:0"
))
func_config
.
default_placement_scope
(
flow
.
scope
.
placement
(
"gpu"
,
"0:0"
))
func_config
.
default_data_type
(
flow
.
float
)
flow
.
config
.
machine_num
(
2
)
flow
.
config
.
gpu_device_num
(
1
)
@
flow
.
global_function
(
func_config
)
def
ReluJob
(
x
=
flow
.
MirroredTensorDef
((
10
,
2
))):
with
flow
.
fixed_
placement
(
"gpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"gpu"
,
"0:0"
):
out0
=
flow
.
keras
.
activations
.
relu
(
x
)
with
flow
.
fixed_
placement
(
"gpu"
,
"1:0"
):
with
flow
.
scope
.
placement
(
"gpu"
,
"1:0"
):
out1
=
flow
.
keras
.
activations
.
relu
(
out0
)
with
flow
.
fixed_
placement
(
"gpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"gpu"
,
"0:0"
):
out2
=
flow
.
keras
.
activations
.
relu
(
out1
)
return
out2
...
...
@@ -88,18 +88,18 @@ def test_multi_node_comm_net_dynamic(test_case):
def
test_multi_node_comm_net_dynamic_empty
(
test_case
):
func_config
=
flow
.
FunctionConfig
()
func_config
.
default_distribute_strategy
(
flow
.
scope
.
mirrored_view
())
func_config
.
default_placement_scope
(
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_placement_scope
(
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_data_type
(
flow
.
float
)
flow
.
config
.
machine_num
(
2
)
flow
.
config
.
gpu_device_num
(
1
)
@
flow
.
global_function
(
func_config
)
def
ReluJob
(
x
=
flow
.
MirroredTensorDef
((
10
,
2
))):
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
out0
=
flow
.
keras
.
activations
.
relu
(
x
)
with
flow
.
fixed_
placement
(
"cpu"
,
"1:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"1:0"
):
out1
=
flow
.
keras
.
activations
.
relu
(
out0
)
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
out2
=
flow
.
keras
.
activations
.
relu
(
out1
)
return
out2
...
...
oneflow/python/test/ops/test_dynamic_binary.py
浏览文件 @
33f512e6
...
...
@@ -6,7 +6,7 @@ import oneflow as flow
def
test_multi_node_dynamic_binary_split_concat_empty
(
test_case
):
func_config
=
flow
.
FunctionConfig
()
func_config
.
default_distribute_strategy
(
flow
.
scope
.
mirrored_view
())
func_config
.
default_placement_scope
(
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_placement_scope
(
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_data_type
(
flow
.
float
)
flow
.
config
.
machine_num
(
2
)
flow
.
config
.
gpu_device_num
(
1
)
...
...
@@ -14,7 +14,7 @@ def test_multi_node_dynamic_binary_split_concat_empty(test_case):
@
flow
.
global_function
(
func_config
)
def
DynamicBinaryJob
(
x
=
flow
.
MirroredTensorDef
((
20
,))):
print
(
"in_shape: "
,
x
.
shape
)
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
out_list
=
flow
.
experimental
.
dynamic_binary_split
(
x
,
base_shift
=
4
,
out_num
=
6
)
...
...
@@ -22,10 +22,10 @@ def test_multi_node_dynamic_binary_split_concat_empty(test_case):
for
out_blob
in
out_list
:
print
(
"out_shape: "
,
out_blob
.
shape
)
id_out_list
.
append
(
flow
.
identity
(
out_blob
))
with
flow
.
fixed_
placement
(
"cpu"
,
"1:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"1:0"
):
out1
=
flow
.
experimental
.
dynamic_binary_concat
(
id_out_list
,
x
)
print
(
"concat_shape: "
,
out1
.
shape
)
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
out2
=
flow
.
identity
(
out1
)
print
(
"return_shape: "
,
out2
.
shape
)
return
out2
...
...
oneflow/python/test/ops/test_expand_dims.py
浏览文件 @
33f512e6
...
...
@@ -23,7 +23,7 @@ def compare_with_tensorflow(device_type, x_shape, axis):
@
flow
.
global_function
(
func_config
)
def
ExpandDimsJob
():
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
x
=
flow
.
get_variable
(
"var"
,
shape
=
x_shape
,
...
...
oneflow/python/test/ops/test_function_config.py
浏览文件 @
33f512e6
...
...
@@ -3,7 +3,7 @@ import oneflow as flow
def
test_default_placement_scope
(
test_case
):
func_config
=
flow
.
FunctionConfig
()
func_config
.
default_placement_scope
(
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_placement_scope
(
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
))
@
flow
.
global_function
(
func_config
)
def
Foo
():
...
...
@@ -21,7 +21,7 @@ def test_config_setter_getter(test_case):
def
test_global_function_desc
(
test_case
):
func_config
=
flow
.
FunctionConfig
()
func_config
.
default_placement_scope
(
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_placement_scope
(
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
))
@
flow
.
global_function
(
func_config
)
def
Foo
():
...
...
oneflow/python/test/ops/test_gather_model_parallel.py
浏览文件 @
33f512e6
...
...
@@ -31,7 +31,7 @@ def _test_gather_model_parallel_fw(
params
=
flow
.
FixedTensorDef
(
params_shape
,
dtype
=
flow
.
float
),
indices
=
flow
.
FixedTensorDef
(
indices_shape
,
dtype
=
flow
.
int32
),
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0-3"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0-3"
):
params
=
params
.
with_distribute
(
flow
.
distribute
.
split
(
split_axis
))
indices
=
indices
.
with_distribute
(
flow
.
distribute
.
broadcast
())
return
flow
.
gather
(
params
=
params
,
indices
=
indices
,
axis
=
axis
)
...
...
oneflow/python/test/ops/test_indexed_slices_reduce_sum.py
浏览文件 @
33f512e6
...
...
@@ -29,7 +29,7 @@ def _run_test(test_case, indices, values, indices_dtype, values_dtype, device):
indices
=
flow
.
FixedTensorDef
(
indices
.
shape
,
dtype
=
indices_dtype
),
values
=
flow
.
FixedTensorDef
(
values
.
shape
,
dtype
=
values_dtype
),
):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
return
flow
.
experimental
.
indexed_slices_reduce_sum
(
indices
,
values
)
out_indices
,
out_values
,
num_unique
=
TestJob
(
indices
,
values
).
get
()
...
...
oneflow/python/test/ops/test_keep_header_only_cpu.py
浏览文件 @
33f512e6
...
...
@@ -9,7 +9,7 @@ func_config.default_distribute_strategy(flow.scope.consistent_view())
def
test_keep_header_only_cpu
(
test_case
):
@
flow
.
global_function
(
func_config
)
def
job
(
x
=
flow
.
FixedTensorDef
((
2
,
3
,
4
),
dtype
=
flow
.
float
)):
with
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
):
with
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
):
x
=
flow
.
identity
(
x
)
return
flow
.
math
.
reduced_shape_elem_cnt
(
x
)
...
...
oneflow/python/test/ops/test_multiply.py
浏览文件 @
33f512e6
...
...
@@ -48,7 +48,7 @@ def _test_element_wise_mul_fw_bw(test_case, device, shape, type_name):
x
=
flow
.
FixedTensorDef
(
shape
,
dtype
=
flow
.
float
),
y
=
flow
.
FixedTensorDef
(
shape
,
dtype
=
flow
.
float
),
):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
x
+=
flow
.
get_variable
(
name
=
"vx"
,
shape
=
(
1
,),
...
...
oneflow/python/test/ops/test_one_hot.py
浏览文件 @
33f512e6
...
...
@@ -26,7 +26,7 @@ def _run_test(
def
one_hot_job
(
x
=
flow
.
FixedTensorDef
(
x_shape
,
dtype
=
type_name_to_flow_type
[
dtype
])
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
one_hot
(
x
,
depth
=
depth
,
...
...
oneflow/python/test/ops/test_prelu.py
浏览文件 @
33f512e6
...
...
@@ -37,7 +37,7 @@ def _run_test(test_case, device_type, dtype, x_shape, shared_axes):
@
flow
.
global_function
(
func_config
)
def
PreluJob
(
x
=
flow
.
FixedTensorDef
(
x_shape
,
dtype
=
type_name_to_flow_type
[
dtype
])):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
x
+=
flow
.
get_variable
(
name
=
"v1"
,
shape
=
(
1
,),
...
...
oneflow/python/test/ops/test_shuffle.py
浏览文件 @
33f512e6
...
...
@@ -27,7 +27,7 @@ def test_shuffle(_):
def
TestJob
(
x
=
flow
.
FixedTensorDef
(
x_shape
,
dtype
=
type_name_to_flow_type
[
data_type
])
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
random
.
shuffle
(
x
)
x
=
np
.
random
.
randn
(
*
x_shape
).
astype
(
type_name_to_np_type
[
data_type
])
...
...
@@ -47,7 +47,7 @@ def test_shuffle(_):
def
TestJob1
(
x
=
flow
.
FixedTensorDef
(
x_shape
,
dtype
=
type_name_to_flow_type
[
data_type
])
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
random
.
generate_random_batch_permutation_indices
(
x
)
x
=
np
.
random
.
randn
(
*
x_shape
).
astype
(
type_name_to_np_type
[
data_type
])
...
...
oneflow/python/test/ops/test_smooth_l1_loss.py
浏览文件 @
33f512e6
...
...
@@ -93,7 +93,7 @@ def test_smooth_l1_loss(_):
)
flow
.
watch_diff
(
v
,
assert_prediction_grad
)
prediction
+=
v
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
loss
=
flow
.
smooth_l1_loss
(
prediction
,
label
,
beta
)
flow
.
losses
.
add_loss
(
loss
)
return
loss
...
...
oneflow/python/test/ops/test_sort.py
浏览文件 @
33f512e6
...
...
@@ -24,7 +24,7 @@ def compare_with_tensorflow(device_type, in_shape, direction, data_type):
dtype
=
type_name_to_flow_type
[
data_type
],
)
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
sort
(
input
,
direction
)
input
=
(
np
.
random
.
random
(
in_shape
)
*
100
).
astype
(
type_name_to_np_type
[
data_type
])
...
...
oneflow/python/test/ops/test_square_sum.py
浏览文件 @
33f512e6
...
...
@@ -13,7 +13,7 @@ def _check(test_case, x, y):
def
_run_test
(
test_case
,
x
,
dtype
,
device
):
@
flow
.
global_function
(
func_config
)
def
SquareSum
(
x
=
flow
.
FixedTensorDef
(
x
.
shape
,
dtype
=
dtype
)):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
return
flow
.
experimental
.
square_sum
(
x
)
y
=
SquareSum
(
x
).
get
()
...
...
oneflow/python/test/ops/test_squeeze.py
浏览文件 @
33f512e6
...
...
@@ -23,7 +23,7 @@ def compare_with_tensorflow(device_type, x_shape, axis):
@
flow
.
global_function
(
func_config
)
def
SqueezeJob
():
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
x
=
flow
.
get_variable
(
"var"
,
shape
=
x_shape
,
...
...
oneflow/python/test/ops/test_sync_dynamic_resize.py
浏览文件 @
33f512e6
...
...
@@ -27,7 +27,7 @@ def test_sync_dynamic_resize(_):
x
=
flow
.
FixedTensorDef
(
x_shape
,
dtype
=
type_name_to_flow_type
[
data_type
]),
size
=
flow
.
FixedTensorDef
((
1
,),
dtype
=
type_name_to_flow_type
[
size_type
]),
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
sync_dynamic_resize
(
x
,
size
)
size
=
np
.
random
.
randint
(
0
,
x_shape
[
0
])
...
...
oneflow/python/test/ops/test_top_k.py
浏览文件 @
33f512e6
...
...
@@ -24,7 +24,7 @@ def compare_with_tensorflow(device_type, in_shape, k, data_type, sorted):
dtype
=
type_name_to_flow_type
[
data_type
],
)
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
return
flow
.
math
.
top_k
(
input
,
k
,
sorted
)
input
=
(
np
.
random
.
random
(
in_shape
)
*
100
).
astype
(
type_name_to_np_type
[
data_type
])
...
...
oneflow/python/test/ops/test_two_stage_reduce.py
浏览文件 @
33f512e6
...
...
@@ -34,14 +34,14 @@ def _test_two_stage_reduce(
@
flow
.
global_function
(
func_config
)
def
two_stage_reduce_job
(
x
=
flow
.
FixedTensorDef
((
4
,
20
,
20
,
20
))):
with
flow
.
fixed_
placement
(
device_type
,
"0:0"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0"
):
x
+=
flow
.
get_variable
(
name
=
"v1"
,
shape
=
(
1
,),
dtype
=
flow
.
float
,
initializer
=
flow
.
zeros_initializer
(),
)
with
flow
.
fixed_
placement
(
device_type
,
"0:0-3"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0-3"
):
loss
=
flow_func
(
x
.
with_distribute
(
flow
.
distribute
.
split
(
split_axis
)),
axis
=
axis
,
...
...
oneflow/python/test/ops/test_unary_elementwise_ops.py
浏览文件 @
33f512e6
...
...
@@ -65,7 +65,7 @@ def test_acos_consistent_1n2c(test_case):
def
test_acos_cpu
(
test_case
):
func_config
=
flow
.
FunctionConfig
()
func_config
.
default_data_type
(
flow
.
float
)
func_config
.
default_placement_scope
(
flow
.
fixed_
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_placement_scope
(
flow
.
scope
.
placement
(
"cpu"
,
"0:0"
))
func_config
.
default_distribute_strategy
(
flow
.
scope
.
consistent_view
())
@
flow
.
global_function
(
func_config
)
...
...
oneflow/python/test/ops/test_unique.py
浏览文件 @
33f512e6
...
...
@@ -23,7 +23,7 @@ def _check_unique(test_case, x, y, idx, count, num_unique):
def
_run_test
(
test_case
,
x
,
dtype
,
device
):
@
flow
.
global_function
(
func_config
)
def
UniqueWithCountsJob
(
x
=
flow
.
FixedTensorDef
(
x
.
shape
,
dtype
=
dtype
)):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
return
flow
.
experimental
.
unique_with_counts
(
x
)
y
,
idx
,
count
,
num_unique
=
UniqueWithCountsJob
(
x
).
get
()
...
...
oneflow/python/test/ops/test_unsorted_batch_segment_sum.py
浏览文件 @
33f512e6
...
...
@@ -54,7 +54,7 @@ def _make_unsoted_segment_sum_fn(device, data, segment_ids, num_segments):
data
=
flow
.
FixedTensorDef
(
data
.
shape
,
dtype
=
flow
.
float
),
segment_ids
=
flow
.
FixedTensorDef
(
segment_ids
.
shape
,
dtype
=
flow
.
int32
),
):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
x
=
flow
.
get_variable
(
"data"
,
shape
=
data
.
shape
,
...
...
oneflow/python/test/ops/test_unsorted_segment_sum.py
浏览文件 @
33f512e6
...
...
@@ -51,7 +51,7 @@ def _run_test(test_case, device, out_shape, axis, segment_ids_shape):
data
=
flow
.
FixedTensorDef
(
data
.
shape
,
dtype
=
flow
.
float
),
segment_ids
=
flow
.
FixedTensorDef
(
segment_ids
.
shape
,
dtype
=
flow
.
int32
),
):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
return
flow
.
math
.
unsorted_segment_sum
(
data
=
data
,
segment_ids
=
segment_ids
,
...
...
@@ -65,7 +65,7 @@ def _run_test(test_case, device, out_shape, axis, segment_ids_shape):
segment_ids
=
flow
.
FixedTensorDef
(
segment_ids
.
shape
,
dtype
=
flow
.
int32
),
like
=
flow
.
FixedTensorDef
(
out_shape
,
dtype
=
flow
.
float32
),
):
with
flow
.
fixed_
placement
(
device
,
"0:0"
):
with
flow
.
scope
.
placement
(
device
,
"0:0"
):
return
flow
.
math
.
unsorted_segment_sum_like
(
data
=
data
,
segment_ids
=
segment_ids
,
like
=
like
,
axis
=
axis
)
...
...
oneflow/python/test/ops/test_unsorted_segment_sum_model_parallel.py
浏览文件 @
33f512e6
...
...
@@ -53,7 +53,7 @@ def _test_unsorted_segment_sum_model_parallel_fw(
segment_ids
=
flow
.
FixedTensorDef
(
segment_ids_arr
.
shape
,
dtype
=
flow
.
int32
),
like
=
flow
.
FixedTensorDef
(
out_arr
.
shape
,
dtype
=
flow
.
float
),
):
with
flow
.
fixed_
placement
(
device_type
,
"0:0-3"
):
with
flow
.
scope
.
placement
(
device_type
,
"0:0-3"
):
if
split_axis
<
axis
:
data
=
data
.
with_distribute
(
flow
.
distribute
.
split
(
split_axis
))
elif
split_axis
==
axis
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录