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
gaoqiong
MIGraphX
Commits
0f7d5123
Commit
0f7d5123
authored
Oct 09, 2022
by
Paul
Browse files
Fixes
parent
64285523
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
14 deletions
+29
-14
tools/tune_ck.py
tools/tune_ck.py
+29
-14
No files found.
tools/tune_ck.py
View file @
0f7d5123
import
os
,
json
,
subprocess
,
tempfile
,
sys
,
argparse
import
os
,
json
,
subprocess
,
tempfile
,
sys
,
argparse
,
contextlib
@
contextlib
.
contextmanager
def
tmp_file
(
dump
=
None
):
tmp_name
=
None
try
:
with
tempfile
.
NamedTemporaryFile
(
mode
=
'w+'
,
delete
=
False
)
as
f
:
tmp_name
=
f
.
name
if
dump
:
dump
(
f
)
yield
tmp_name
finally
:
os
.
unlink
(
tmp_name
)
def
pretty_print
(
obj
):
print
(
json
.
dumps
(
obj
,
indent
=
4
))
def
benchmark_one
(
config
,
tuning
):
def
benchmark_one
(
config
,
tuning
):
with
tempfile
.
NamedTemporaryFile
(
mode
=
"w+"
)
as
tf
:
b
=
{
b
=
{
'settings'
:
{
'settings'
:
{
'iterations'
:
100
'iterations'
:
100
},
},
'compile_op'
:
{
'compile_op'
:
{
'name'
:
'ck_gemm'
,
'name'
:
'ck_gemm'
,
'tuning_val'
:
tuning
,
'tuning_val'
:
tuning
,
'inputs'
:
config
'inputs'
:
config
}
}
}
json
.
dump
(
b
,
tf
)
}
cp
=
subprocess
.
run
(
'./bin/gpu-driver {}'
.
format
(
tf
.
name
),
print
(
b
)
capture_output
=
True
)
with
tmp_file
(
lambda
tf
:
json
.
dump
(
b
,
tf
))
as
tf
:
cp
=
subprocess
.
run
(
'./bin/gpu-driver {}'
.
format
(
tf
),
capture_output
=
True
,
shell
=
True
)
for
line
in
cp
.
stdout
.
decode
().
split
(
"
\n
"
):
for
line
in
cp
.
stdout
.
decode
().
split
(
"
\n
"
):
s
=
line
.
strip
()
s
=
line
.
strip
()
if
not
s
:
if
not
s
:
continue
continue
fields
=
s
.
split
(
','
)
fields
=
s
.
split
(
','
)
dtime
=
fields
[
-
1
].
strip
()
dtime
=
fields
[
-
1
].
strip
()
print
(
dtime
)
return
float
(
dtime
[:
-
2
])
return
float
(
dtime
[:
-
2
])
return
sys
.
float_info
.
max
return
sys
.
float_info
.
max
...
...
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