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
7a387096
Commit
7a387096
authored
Nov 14, 2022
by
charlie
Browse files
Added tool scripts
parent
df2e7635
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
285 additions
and
0 deletions
+285
-0
tools/all_onnx_ops.txt
tools/all_onnx_ops.txt
+186
-0
tools/check_onnx_op_support.py
tools/check_onnx_op_support.py
+16
-0
tools/generate_models.py
tools/generate_models.py
+83
-0
No files found.
tools/all_onnx_ops.txt
0 → 100644
View file @
7a387096
Abs
Acos
Acosh
Add
And
ArgMax
ArgMin
Asin
Asinh
Atan
Atanh
AveragePool
BatchNormalization
BitShift
BitwiseAnd
BitwiseNot
BitwiseOr
BitwiseXor
Cast
Ceil
Col2Im
Compress
Concat
ConcatFromSequence
Constant
ConstantOfShape
Conv
ConvInteger
ConvTranspose
Cos
Cosh
CumSum
DFT
DepthToSpace
DequantizeLinear
Det
Div
Dropout
Einsum
Equal
Erf
Exp
Expand
EyeLike
Flatten
Floor
GRU
Gather
GatherElements
GatherND
Gemm
GlobalAveragePool
GlobalLpPool
GlobalMaxPool
Greater
GridSample
Hardmax
Identity
If
InstanceNormalization
IsInf
IsNaN
LRN
LSTM
Less
Log
Loop
LpNormalization
LpPool
MatMul
MatMulInteger
Max
MaxPool
MaxRoiPool
MaxUnpool
Mean
MelWeightMatrix
Min
Mod
Mul
Multinomial
Neg
NonMaxSuppression
NonZero
Not
OneHot
Optional
OptionalGetElement
OptionalHasElement
Or
Pad
Pow
QLinearConv
QLinearMatMul
QuantizeLinear
RNN
RandomNormal
RandomNormalLike
RandomUniform
RandomUniformLike
Reciprocal
ReduceL1
ReduceL2
ReduceLogSum
ReduceLogSumExp
ReduceMax
ReduceMean
ReduceMin
ReduceProd
ReduceSum
ReduceSumSquare
Reshape
Resize
ReverseSequence
RoiAlign
Round
STFT
Scan
Scatter
ScatterElements
ScatterND
SequenceAt
SequenceConstruct
SequenceEmpty
SequenceErase
SequenceInsert
SequenceLength
Shape
Sigmoid
Sign
Sin
Sinh
Size
Slice
SpaceToDepth
Split
SplitToSequence
Sqrt
Squeeze
StringNormalizer
Sub
Sum
Tan
Tanh
TfIdfVectorizer
Tile
TopK
Transpose
Trilu
Unique
Unsqueeze
Upsample
Where
Xor
Bernoulli
BlackmanWindow
CastLike
Celu
CenterCropPad
Clip
DynamicQuantizeLinear
Elu
GreaterOrEqual
GroupNormalization
HammingWindow
HannWindow
HardSigmoid
HardSwish
LayerNormalization
LeakyRelu
LessOrEqual
LogSoftmax
MeanVarianceNormalization
Mish
NegativeLogLikelihoodLoss
PRelu
Range
Relu
Selu
SequenceMap
Shrink
Softmax
SoftmaxCrossEntropyLoss
Softplus
Softsign
ThresholdedRelu
tools/check_onnx_op_support.py
0 → 100644
View file @
7a387096
#!/usr/bin/env python3
import
subprocess
onnx_dir
=
"../src/onnx"
ops_supported
=
[]
with
open
(
"all_onnx_ops.txt"
,
"r"
)
as
f
:
for
op
in
f
.
readlines
():
op
=
op
.
rstrip
(
"
\n
"
)
result
=
subprocess
.
run
(
[
"grep"
,
"-q"
,
"-n"
,
"--directories=recurse"
,
op
,
onnx_dir
])
if
result
.
returncode
==
0
:
ops_supported
.
append
(
op
)
for
op
in
ops_supported
:
print
(
op
)
tools/generate_models.py
0 → 100644
View file @
7a387096
import
os
,
sys
,
subprocess
,
string
__source_dir__
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
realpath
(
__file__
),
'..'
,
'..'
))
driver_exe
=
os
.
path
.
abspath
(
sys
.
argv
[
1
])
cpp_function
=
string
.
Template
(
'''
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/make_op.hpp>
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/json.hpp>
#include "models.hpp"
namespace migraphx {
namespace driver {
inline namespace MIGRAPHX_INLINE_NS {
migraphx::program ${name}(unsigned batch) // NOLINT(readability-function-size)
{
${body}
return p;
}
} // namespace MIGRAPHX_INLINE_NS
} // namespace driver
} // namespace migraphx
'''
)
def
sed
(
cmd
,
extended
=
False
):
flags
=
''
if
extended
:
flags
=
'-E'
return
f
"| sed
{
flags
}
'
{
cmd
}
'"
def
get_generated_body
(
model
):
run_driver
=
f
"
{
driver_exe
}
read --cpp
{
model
}
| sed '/Reading/d'"
cmd
=
run_driver
+
sed
(
'/add_parameter/s/{1,/{batch,/'
)
+
sed
(
's/
\\\\\\
"(
\\
w+)
\\\\\\
":/
\\
1:/g'
,
extended
=
True
)
# cmd = run_driver + " | sed '/add_parameter/s/{1,/{batch,/'"
cp
=
subprocess
.
run
(
cmd
,
shell
=
True
,
capture_output
=
True
,
check
=
True
,
text
=
True
)
return
cp
.
stdout
def
generate_cpp
(
name
,
body
):
return
cpp_function
.
substitute
(
name
=
name
,
body
=
body
)
models
=
{
'resnet50'
:
'/codes/onnx_models/resnet50_v1.onnx'
,
'alexnet'
:
'/codes/onnx_models/bvlcalexnet-12.onnx'
,
'inceptionv3'
:
'/codes/onnx_models/inceptionv3_fp32.onnx'
}
for
name
,
model
in
models
.
items
():
src
=
generate_cpp
(
name
,
get_generated_body
(
model
))
cpp_path
=
os
.
path
.
join
(
__source_dir__
,
"src"
,
"driver"
,
name
+
'.cpp'
)
# print(src)
with
open
(
cpp_path
,
'w'
)
as
f
:
f
.
write
(
src
)
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