Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
88ef6c04
Unverified
Commit
88ef6c04
authored
Aug 01, 2019
by
SparkSnail
Committed by
GitHub
Aug 01, 2019
Browse files
Merge pull request #197 from microsoft/master
merge master
parents
5f3c5ffd
555334de
Changes
48
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
123 additions
and
7 deletions
+123
-7
test/pipelines-it-local-windows.yml
test/pipelines-it-local-windows.yml
+4
-0
test/pipelines-it-local.yml
test/pipelines-it-local.yml
+4
-0
tools/nni_annotation/search_space_generator.py
tools/nni_annotation/search_space_generator.py
+2
-2
tools/nni_annotation/test_annotation.py
tools/nni_annotation/test_annotation.py
+2
-1
tools/nni_annotation/testcase/annotated/nas.py
tools/nni_annotation/testcase/annotated/nas.py
+49
-0
tools/nni_annotation/testcase/searchspace.json
tools/nni_annotation/testcase/searchspace.json
+42
-0
tools/nni_annotation/testcase/usercode/nas.py
tools/nni_annotation/testcase/usercode/nas.py
+0
-0
tools/nni_cmd/config_schema.py
tools/nni_cmd/config_schema.py
+20
-4
No files found.
test/pipelines-it-local-windows.yml
View file @
88ef6c04
...
@@ -36,3 +36,7 @@ jobs:
...
@@ -36,3 +36,7 @@ jobs:
cd test
cd test
python metrics_test.py
python metrics_test.py
displayName
:
'
Trial
job
metrics
test'
displayName
:
'
Trial
job
metrics
test'
-
script
:
|
cd test
PATH=$HOME/.local/bin:$PATH python3 cli_test.py
displayName
:
'
nnicli
test'
test/pipelines-it-local.yml
View file @
88ef6c04
...
@@ -37,3 +37,7 @@ jobs:
...
@@ -37,3 +37,7 @@ jobs:
cd test
cd test
PATH=$HOME/.local/bin:$PATH python3 metrics_test.py
PATH=$HOME/.local/bin:$PATH python3 metrics_test.py
displayName
:
'
Trial
job
metrics
test'
displayName
:
'
Trial
job
metrics
test'
-
script
:
|
cd test
PATH=$HOME/.local/bin:$PATH python3 cli_test.py
displayName
:
'
nnicli
test'
tools/nni_annotation/search_space_generator.py
View file @
88ef6c04
...
@@ -57,8 +57,8 @@ class SearchSpaceGenerator(ast.NodeTransformer):
...
@@ -57,8 +57,8 @@ class SearchSpaceGenerator(ast.NodeTransformer):
key
=
self
.
module_name
+
'/'
+
mutable_block
key
=
self
.
module_name
+
'/'
+
mutable_block
args
[
0
].
s
=
key
args
[
0
].
s
=
key
if
key
not
in
self
.
search_space
:
if
key
not
in
self
.
search_space
:
self
.
search_space
[
key
]
=
dict
()
self
.
search_space
[
key
]
=
{
'_type'
:
'mutable_layer'
,
'_value'
:
{}}
self
.
search_space
[
key
][
mutable_layer
]
=
{
self
.
search_space
[
key
][
'_value'
][
mutable_layer
]
=
{
'layer_choice'
:
[
k
.
s
for
k
in
args
[
2
].
keys
],
'layer_choice'
:
[
k
.
s
for
k
in
args
[
2
].
keys
],
'optional_inputs'
:
[
k
.
s
for
k
in
args
[
5
].
keys
],
'optional_inputs'
:
[
k
.
s
for
k
in
args
[
5
].
keys
],
'optional_input_size'
:
args
[
6
].
n
if
isinstance
(
args
[
6
],
ast
.
Num
)
else
[
args
[
6
].
elts
[
0
].
n
,
args
[
6
].
elts
[
1
].
n
]
'optional_input_size'
:
args
[
6
].
n
if
isinstance
(
args
[
6
],
ast
.
Num
)
else
[
args
[
6
].
elts
[
0
].
n
,
args
[
6
].
elts
[
1
].
n
]
...
...
tools/nni_annotation/test_annotation.py
View file @
88ef6c04
...
@@ -44,8 +44,9 @@ class AnnotationTestCase(TestCase):
...
@@ -44,8 +44,9 @@ class AnnotationTestCase(TestCase):
self
.
assertEqual
(
search_space
,
json
.
load
(
f
))
self
.
assertEqual
(
search_space
,
json
.
load
(
f
))
def
test_code_generator
(
self
):
def
test_code_generator
(
self
):
code_dir
=
expand_annotations
(
'testcase/usercode'
,
'_generated'
)
code_dir
=
expand_annotations
(
'testcase/usercode'
,
'_generated'
,
nas_mode
=
'classic_mode'
)
self
.
assertEqual
(
code_dir
,
'_generated'
)
self
.
assertEqual
(
code_dir
,
'_generated'
)
self
.
_assert_source_equal
(
'testcase/annotated/nas.py'
,
'_generated/nas.py'
)
self
.
_assert_source_equal
(
'testcase/annotated/mnist.py'
,
'_generated/mnist.py'
)
self
.
_assert_source_equal
(
'testcase/annotated/mnist.py'
,
'_generated/mnist.py'
)
self
.
_assert_source_equal
(
'testcase/annotated/dir/simple.py'
,
'_generated/dir/simple.py'
)
self
.
_assert_source_equal
(
'testcase/annotated/dir/simple.py'
,
'_generated/dir/simple.py'
)
with
open
(
'testcase/usercode/nonpy.txt'
)
as
src
,
open
(
'_generated/nonpy.txt'
)
as
dst
:
with
open
(
'testcase/usercode/nonpy.txt'
)
as
src
,
open
(
'_generated/nonpy.txt'
)
as
dst
:
...
...
tools/nni_annotation/testcase/annotated/nas.py
0 → 100644
View file @
88ef6c04
import
nni
import
time
def
add_one
(
inputs
):
return
inputs
+
1
def
add_two
(
inputs
):
return
inputs
+
2
def
add_three
(
inputs
):
return
inputs
+
3
def
add_four
(
inputs
):
return
inputs
+
4
def
main
():
images
=
5
layer_1_out
=
nni
.
mutable_layer
(
'mutable_block_39'
,
'mutable_layer_0'
,
{
'add_one()'
:
add_one
,
'add_two()'
:
add_two
,
'add_three()'
:
add_three
,
'add_four()'
:
add_four
},
{
'add_one()'
:
{},
'add_two()'
:
{},
'add_three()'
:
{},
'add_four()'
:
{}},
[],
{
'images'
:
images
},
1
,
'classic_mode'
)
layer_2_out
=
nni
.
mutable_layer
(
'mutable_block_39'
,
'mutable_layer_1'
,
{
'add_one()'
:
add_one
,
'add_two()'
:
add_two
,
'add_three()'
:
add_three
,
'add_four()'
:
add_four
},
{
'add_one()'
:
{},
'add_two()'
:
{},
'add_three()'
:
{},
'add_four()'
:
{}},
[],
{
'layer_1_out'
:
layer_1_out
},
1
,
'classic_mode'
)
layer_3_out
=
nni
.
mutable_layer
(
'mutable_block_39'
,
'mutable_layer_2'
,
{
'add_one()'
:
add_one
,
'add_two()'
:
add_two
,
'add_three()'
:
add_three
,
'add_four()'
:
add_four
},
{
'add_one()'
:
{},
'add_two()'
:
{},
'add_three()'
:
{},
'add_four()'
:
{}},
[],
{
'layer_1_out'
:
layer_1_out
,
'layer_2_out'
:
layer_2_out
},
1
,
'classic_mode'
)
nni
.
report_intermediate_result
(
layer_1_out
)
time
.
sleep
(
2
)
nni
.
report_intermediate_result
(
layer_2_out
)
time
.
sleep
(
2
)
nni
.
report_intermediate_result
(
layer_3_out
)
time
.
sleep
(
2
)
layer_3_out
=
layer_3_out
+
10
nni
.
report_final_result
(
layer_3_out
)
if
__name__
==
'__main__'
:
main
()
tools/nni_annotation/testcase/searchspace.json
View file @
88ef6c04
...
@@ -143,5 +143,47 @@
...
@@ -143,5 +143,47 @@
"(2 * 3 + 4)"
,
"(2 * 3 + 4)"
,
"(lambda x: 1 + x)"
"(lambda x: 1 + x)"
]
]
},
"nas/mutable_block_39"
:
{
"_type"
:
"mutable_layer"
,
"_value"
:
{
"mutable_layer_0"
:
{
"layer_choice"
:
[
"add_one()"
,
"add_two()"
,
"add_three()"
,
"add_four()"
],
"optional_inputs"
:
[
"images"
],
"optional_input_size"
:
1
},
"mutable_layer_1"
:
{
"layer_choice"
:
[
"add_one()"
,
"add_two()"
,
"add_three()"
,
"add_four()"
],
"optional_inputs"
:
[
"layer_1_out"
],
"optional_input_size"
:
1
},
"mutable_layer_2"
:
{
"layer_choice"
:
[
"add_one()"
,
"add_two()"
,
"add_three()"
,
"add_four()"
],
"optional_inputs"
:
[
"layer_1_out"
,
"layer_2_out"
],
"optional_input_size"
:
1
}
}
}
}
}
}
\ No newline at end of file
tools/nni_annotation/testcase/
mutable_layer_
usercode/
simple
.py
→
tools/nni_annotation/testcase/usercode/
nas
.py
View file @
88ef6c04
File moved
tools/nni_cmd/config_schema.py
View file @
88ef6c04
...
@@ -92,6 +92,16 @@ tuner_schema_dict = {
...
@@ -92,6 +92,16 @@ tuner_schema_dict = {
Optional
(
'includeIntermediateResults'
):
setType
(
'includeIntermediateResults'
,
bool
),
Optional
(
'includeIntermediateResults'
):
setType
(
'includeIntermediateResults'
,
bool
),
Optional
(
'gpuNum'
):
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
Optional
(
'gpuNum'
):
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
},
},
'TPE'
:
{
'builtinTunerName'
:
'TPE'
,
'classArgs'
:
{
Optional
(
'optimize_mode'
):
setChoice
(
'optimize_mode'
,
'maximize'
,
'minimize'
),
Optional
(
'parallel_optimize'
):
setType
(
'parallel_optimize'
,
bool
),
Optional
(
'constant_liar_type'
):
setChoice
(
'constant_liar_type'
,
'min'
,
'max'
,
'mean'
)
},
Optional
(
'includeIntermediateResults'
):
setType
(
'includeIntermediateResults'
,
bool
),
Optional
(
'gpuNum'
):
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
},
'NetworkMorphism'
:
{
'NetworkMorphism'
:
{
'builtinTunerName'
:
'NetworkMorphism'
,
'builtinTunerName'
:
'NetworkMorphism'
,
'classArgs'
:
{
'classArgs'
:
{
...
@@ -223,6 +233,8 @@ pai_trial_schema = {
...
@@ -223,6 +233,8 @@ pai_trial_schema = {
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'image'
:
setType
(
'image'
,
str
),
'image'
:
setType
(
'image'
,
str
),
Optional
(
'authFile'
):
And
(
Regex
(
r
'hdfs://(([0-9]{1,3}.){3}[0-9]{1,3})(:[0-9]{2,5})?(/.*)?'
),
\
error
=
'ERROR: authFile format error, authFile format is hdfs://xxx.xxx.xxx.xxx:xxx'
),
Optional
(
'shmMB'
):
setType
(
'shmMB'
,
int
),
Optional
(
'shmMB'
):
setType
(
'shmMB'
,
int
),
Optional
(
'dataDir'
):
And
(
Regex
(
r
'hdfs://(([0-9]{1,3}.){3}[0-9]{1,3})(:[0-9]{2,5})?(/.*)?'
),
\
Optional
(
'dataDir'
):
And
(
Regex
(
r
'hdfs://(([0-9]{1,3}.){3}[0-9]{1,3})(:[0-9]{2,5})?(/.*)?'
),
\
error
=
'ERROR: dataDir format error, dataDir format is hdfs://xxx.xxx.xxx.xxx:xxx'
),
error
=
'ERROR: dataDir format error, dataDir format is hdfs://xxx.xxx.xxx.xxx:xxx'
),
...
@@ -251,7 +263,8 @@ kubeflow_trial_schema = {
...
@@ -251,7 +263,8 @@ kubeflow_trial_schema = {
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'image'
:
setType
(
'image'
,
str
)
'image'
:
setType
(
'image'
,
str
),
Optional
(
'privateRegistryAuthPath'
):
And
(
os
.
path
.
exists
,
error
=
SCHEMA_PATH_ERROR
%
'privateRegistryAuthPath'
)
},
},
Optional
(
'master'
):
{
Optional
(
'master'
):
{
'replicas'
:
setType
(
'replicas'
,
int
),
'replicas'
:
setType
(
'replicas'
,
int
),
...
@@ -259,7 +272,8 @@ kubeflow_trial_schema = {
...
@@ -259,7 +272,8 @@ kubeflow_trial_schema = {
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'image'
:
setType
(
'image'
,
str
)
'image'
:
setType
(
'image'
,
str
),
Optional
(
'privateRegistryAuthPath'
):
And
(
os
.
path
.
exists
,
error
=
SCHEMA_PATH_ERROR
%
'privateRegistryAuthPath'
)
},
},
Optional
(
'worker'
):{
Optional
(
'worker'
):{
'replicas'
:
setType
(
'replicas'
,
int
),
'replicas'
:
setType
(
'replicas'
,
int
),
...
@@ -267,7 +281,8 @@ kubeflow_trial_schema = {
...
@@ -267,7 +281,8 @@ kubeflow_trial_schema = {
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'image'
:
setType
(
'image'
,
str
)
'image'
:
setType
(
'image'
,
str
),
Optional
(
'privateRegistryAuthPath'
):
And
(
os
.
path
.
exists
,
error
=
SCHEMA_PATH_ERROR
%
'privateRegistryAuthPath'
)
}
}
}
}
}
}
...
@@ -314,7 +329,8 @@ frameworkcontroller_trial_schema = {
...
@@ -314,7 +329,8 @@ frameworkcontroller_trial_schema = {
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'gpuNum'
:
setNumberRange
(
'gpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'cpuNum'
:
setNumberRange
(
'cpuNum'
,
int
,
0
,
99999
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'memoryMB'
:
setType
(
'memoryMB'
,
int
),
'image'
:
setType
(
'image'
,
str
)
'image'
:
setType
(
'image'
,
str
),
Optional
(
'privateRegistryAuthPath'
):
And
(
os
.
path
.
exists
,
error
=
SCHEMA_PATH_ERROR
%
'privateRegistryAuthPath'
)
}]
}]
}
}
}
}
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment