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
94e3a2e4
Commit
94e3a2e4
authored
Feb 12, 2022
by
Shucai Xiao
Browse files
change size_t to int
parent
26bd92d8
Changes
256
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
913 additions
and
94 deletions
+913
-94
src/analyze_streams.cpp
src/analyze_streams.cpp
+5
-5
src/api/api.cpp
src/api/api.cpp
+14
-14
src/api/include/migraphx/migraphx.h
src/api/include/migraphx/migraphx.h
+10
-10
src/api/include/migraphx/migraphx.hpp
src/api/include/migraphx/migraphx.hpp
+27
-27
src/argument.cpp
src/argument.cpp
+7
-7
src/cpp_generator.cpp
src/cpp_generator.cpp
+1
-1
src/dead_code_elimination.cpp
src/dead_code_elimination.cpp
+1
-1
src/driver/alexnet.cpp
src/driver/alexnet.cpp
+1
-1
src/driver/inceptionv3.cpp
src/driver/inceptionv3.cpp
+1
-1
src/driver/main.cpp
src/driver/main.cpp
+3
-3
src/driver/models.hpp
src/driver/models.hpp
+3
-3
src/driver/resnet50.cpp
src/driver/resnet50.cpp
+1
-1
src/driver/verify.cpp
src/driver/verify.cpp
+3
-3
src/dynamic_loader.cpp
src/dynamic_loader.cpp
+2
-2
src/eliminate_allocation.cpp
src/eliminate_allocation.cpp
+2
-2
src/eliminate_pad.cpp
src/eliminate_pad.cpp
+9
-9
src/env.cpp
src/env.cpp
+1
-1
src/file_buffer.cpp
src/file_buffer.cpp
+1
-1
src/files
src/files
+819
-0
src/fuse_pointwise.cpp
src/fuse_pointwise.cpp
+2
-2
No files found.
src/analyze_streams.cpp
View file @
94e3a2e4
...
...
@@ -8,7 +8,7 @@
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
bool
happens_before
(
const
std
::
vector
<
std
::
size_
t
>&
e1
,
const
std
::
vector
<
std
::
size_
t
>&
e2
)
bool
happens_before
(
const
std
::
vector
<
in
t
>&
e1
,
const
std
::
vector
<
in
t
>&
e2
)
{
return
std
::
equal
(
e1
.
begin
(),
e1
.
end
(),
e2
.
begin
(),
e2
.
end
(),
std
::
less_equal
<>
{})
and
not
std
::
equal
(
e1
.
begin
(),
e1
.
end
(),
e2
.
begin
(),
e2
.
end
(),
std
::
greater_equal
<>
{});
...
...
@@ -16,17 +16,17 @@ bool happens_before(const std::vector<std::size_t>& e1, const std::vector<std::s
std
::
vector
<
stream_race
>
analyze_streams
(
const
module
&
p
,
const
stream_model
&
m
)
{
using
vector_clock
=
std
::
vector
<
std
::
size_
t
>
;
using
vector_clock
=
std
::
vector
<
in
t
>
;
std
::
vector
<
stream_race
>
races
;
auto
nstream
=
m
.
get_nstream
();
std
::
vector
<
vector_clock
>
vclock
(
nstream
,
vector_clock
(
nstream
));
std
::
unordered_map
<
instruction_ref
,
vector_clock
>
timestamp
;
std
::
unordered_map
<
std
::
size_
t
,
vector_clock
>
events
;
std
::
unordered_map
<
in
t
,
vector_clock
>
events
;
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
not
m
.
has_stream
(
ins
))
continue
;
std
::
size_
t
s
=
m
.
get_stream
(
ins
);
in
t
s
=
m
.
get_stream
(
ins
);
assert
(
s
<
nstream
);
assert
(
vclock
.
size
()
==
nstream
);
assert
(
vclock
[
s
].
size
()
==
nstream
);
...
...
@@ -63,7 +63,7 @@ std::vector<stream_race> analyze_streams(const module& p, const stream_model& m)
continue
;
if
(
ins
->
inputs
().
empty
())
continue
;
std
::
size_
t
s
=
m
.
get_stream
(
ins
);
in
t
s
=
m
.
get_stream
(
ins
);
// Find inputs from different streams
std
::
vector
<
instruction_ref
>
inputs
;
fix
([
&
](
auto
self
,
auto
start
)
{
...
...
src/api/api.cpp
View file @
94e3a2e4
...
...
@@ -96,12 +96,12 @@ void set_default_dim_value(tf_options& options, size_t value) { options.batch_si
void
set_input_parameter_shape
(
onnx_options
&
options
,
const
char
*
name
,
std
::
vector
<
std
::
size_
t
>
dims
)
std
::
vector
<
in
t
>
dims
)
{
options
.
map_input_dims
[
std
::
string
(
name
)]
=
std
::
move
(
dims
);
}
void
set_input_parameter_shape
(
tf_options
&
options
,
const
char
*
name
,
std
::
vector
<
std
::
size_
t
>
dims
)
void
set_input_parameter_shape
(
tf_options
&
options
,
const
char
*
name
,
std
::
vector
<
in
t
>
dims
)
{
options
.
map_input_dims
[
std
::
string
(
name
)]
=
std
::
move
(
dims
);
}
...
...
@@ -388,7 +388,7 @@ extern "C" migraphx_status migraphx_shape_destroy(migraphx_shape_t shape)
extern
"C"
migraphx_status
migraphx_shape_create
(
migraphx_shape_t
*
shape
,
migraphx_shape_datatype_t
type
,
size_t
*
lengths
,
size_
t
lengths_size
)
in
t
lengths_size
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
lengths
==
nullptr
and
lengths_size
!=
0
)
...
...
@@ -403,9 +403,9 @@ extern "C" migraphx_status migraphx_shape_create(migraphx_shape_t* shape,
extern
"C"
migraphx_status
migraphx_shape_create_with_strides
(
migraphx_shape_t
*
shape
,
migraphx_shape_datatype_t
type
,
size_t
*
lengths
,
size_
t
lengths_size
,
in
t
lengths_size
,
size_t
*
strides
,
size_
t
strides_size
)
in
t
strides_size
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
lengths
==
nullptr
and
lengths_size
!=
0
)
...
...
@@ -431,7 +431,7 @@ extern "C" migraphx_status migraphx_shape_create_scalar(migraphx_shape_t* shape,
}
extern
"C"
migraphx_status
migraphx_shape_lengths
(
const
size_
t
**
out
,
size_
t
*
out_size
,
const_migraphx_shape_t
shape
)
migraphx_shape_lengths
(
const
in
t
**
out
,
in
t
*
out_size
,
const_migraphx_shape_t
shape
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
out
==
nullptr
or
out_size
==
nullptr
)
...
...
@@ -446,7 +446,7 @@ migraphx_shape_lengths(const size_t** out, size_t* out_size, const_migraphx_shap
}
extern
"C"
migraphx_status
migraphx_shape_strides
(
const
size_
t
**
out
,
size_
t
*
out_size
,
const_migraphx_shape_t
shape
)
migraphx_shape_strides
(
const
in
t
**
out
,
in
t
*
out_size
,
const_migraphx_shape_t
shape
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
out
==
nullptr
or
out_size
==
nullptr
)
...
...
@@ -847,7 +847,7 @@ extern "C" migraphx_status migraphx_operation_create(migraphx_operation_t* opera
}
extern
"C"
migraphx_status
migraphx_operation_name
(
char
*
out
,
size_
t
out_size
,
migraphx_operation_t
operation
)
migraphx_operation_name
(
char
*
out
,
in
t
out_size
,
migraphx_operation_t
operation
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
out
==
nullptr
)
...
...
@@ -855,7 +855,7 @@ migraphx_operation_name(char* out, size_t out_size, migraphx_operation_t operati
if
(
operation
==
nullptr
)
MIGRAPHX_THROW
(
migraphx_status_bad_param
,
"Bad parameter operation: Null pointer"
);
auto
&&
api_result
=
(
operation
->
object
).
name
();
auto
*
it
=
std
::
copy_n
(
api_result
.
begin
(),
std
::
min
(
api_result
.
size
(),
out_size
-
1
),
out
);
auto
*
it
=
std
::
copy_n
(
api_result
.
begin
(),
std
::
min
(
static_cast
<
int
>
(
api_result
.
size
()
)
,
out_size
-
1
),
out
);
*
it
=
'\0'
;
});
return
api_error_result
;
...
...
@@ -900,7 +900,7 @@ extern "C" migraphx_status migraphx_onnx_options_create(migraphx_onnx_options_t*
}
extern
"C"
migraphx_status
migraphx_onnx_options_set_input_parameter_shape
(
migraphx_onnx_options_t
onnx_options
,
const
char
*
name
,
size_t
*
dims
,
size_
t
dims_size
)
migraphx_onnx_options_t
onnx_options
,
const
char
*
name
,
size_t
*
dims
,
in
t
dims_size
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
onnx_options
==
nullptr
)
...
...
@@ -908,7 +908,7 @@ extern "C" migraphx_status migraphx_onnx_options_set_input_parameter_shape(
if
(
dims
==
nullptr
and
dims_size
!=
0
)
MIGRAPHX_THROW
(
migraphx_status_bad_param
,
"Bad parameter dims: Null pointer"
);
migraphx
::
set_input_parameter_shape
(
(
onnx_options
->
object
),
(
name
),
(
std
::
vector
<
size_
t
>
(
dims
,
dims
+
dims_size
)));
(
onnx_options
->
object
),
(
name
),
(
std
::
vector
<
in
t
>
(
dims
,
dims
+
dims_size
)));
});
return
api_error_result
;
}
...
...
@@ -1053,7 +1053,7 @@ extern "C" migraphx_status migraphx_tf_options_set_nhwc(migraphx_tf_options_t tf
}
extern
"C"
migraphx_status
migraphx_tf_options_set_input_parameter_shape
(
migraphx_tf_options_t
tf_options
,
const
char
*
name
,
size_
t
*
dims
,
size_
t
dims_size
)
migraphx_tf_options_t
tf_options
,
const
char
*
name
,
in
t
*
dims
,
in
t
dims_size
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
tf_options
==
nullptr
)
...
...
@@ -1061,7 +1061,7 @@ extern "C" migraphx_status migraphx_tf_options_set_input_parameter_shape(
if
(
dims
==
nullptr
and
dims_size
!=
0
)
MIGRAPHX_THROW
(
migraphx_status_bad_param
,
"Bad parameter dims: Null pointer"
);
migraphx
::
set_input_parameter_shape
(
(
tf_options
->
object
),
(
name
),
(
std
::
vector
<
size_
t
>
(
dims
,
dims
+
dims_size
)));
(
tf_options
->
object
),
(
name
),
(
std
::
vector
<
in
t
>
(
dims
,
dims
+
dims_size
)));
});
return
api_error_result
;
}
...
...
@@ -1079,7 +1079,7 @@ migraphx_tf_options_set_default_dim_value(migraphx_tf_options_t tf_options, size
extern
"C"
migraphx_status
migraphx_tf_options_set_output_names
(
migraphx_tf_options_t
tf_options
,
const
char
**
names
,
size_
t
names_size
)
in
t
names_size
)
{
auto
api_error_result
=
migraphx
::
try_
([
&
]
{
if
(
tf_options
==
nullptr
)
...
...
src/api/include/migraphx/migraphx.h
View file @
94e3a2e4
...
...
@@ -94,23 +94,23 @@ migraphx_status migraphx_shape_destroy(migraphx_shape_t shape);
migraphx_status
migraphx_shape_create
(
migraphx_shape_t
*
shape
,
migraphx_shape_datatype_t
type
,
size_t
*
lengths
,
size_
t
lengths_size
);
in
t
lengths_size
);
migraphx_status
migraphx_shape_create_with_strides
(
migraphx_shape_t
*
shape
,
migraphx_shape_datatype_t
type
,
size_t
*
lengths
,
size_
t
lengths_size
,
in
t
lengths_size
,
size_t
*
strides
,
size_
t
strides_size
);
in
t
strides_size
);
migraphx_status
migraphx_shape_create_scalar
(
migraphx_shape_t
*
shape
,
migraphx_shape_datatype_t
type
);
migraphx_status
migraphx_shape_lengths
(
const
size_
t
**
out
,
size_
t
*
out_size
,
const_migraphx_shape_t
shape
);
migraphx_shape_lengths
(
const
in
t
**
out
,
in
t
*
out_size
,
const_migraphx_shape_t
shape
);
migraphx_status
migraphx_shape_strides
(
const
size_
t
**
out
,
size_
t
*
out_size
,
const_migraphx_shape_t
shape
);
migraphx_shape_strides
(
const
in
t
**
out
,
in
t
*
out_size
,
const_migraphx_shape_t
shape
);
migraphx_status
migraphx_shape_type
(
migraphx_shape_datatype_t
*
out
,
const_migraphx_shape_t
shape
);
...
...
@@ -212,7 +212,7 @@ migraphx_status migraphx_operation_create(migraphx_operation_t* operation,
const
char
*
attributes
,
...);
migraphx_status
migraphx_operation_name
(
char
*
out
,
size_
t
out_size
,
migraphx_operation_t
operation
);
migraphx_status
migraphx_operation_name
(
char
*
out
,
in
t
out_size
,
migraphx_operation_t
operation
);
migraphx_status
migraphx_load
(
migraphx_program_t
*
out
,
const
char
*
name
,
migraphx_file_options_t
options
);
...
...
@@ -225,7 +225,7 @@ migraphx_status migraphx_onnx_options_destroy(migraphx_onnx_options_t onnx_optio
migraphx_status
migraphx_onnx_options_create
(
migraphx_onnx_options_t
*
onnx_options
);
migraphx_status
migraphx_onnx_options_set_input_parameter_shape
(
migraphx_onnx_options_t
onnx_options
,
const
char
*
name
,
size_t
*
dims
,
size_
t
dims_size
);
migraphx_onnx_options_t
onnx_options
,
const
char
*
name
,
size_t
*
dims
,
in
t
dims_size
);
migraphx_status
migraphx_onnx_options_set_default_dim_value
(
migraphx_onnx_options_t
onnx_options
,
size_t
value
);
...
...
@@ -267,15 +267,15 @@ migraphx_status migraphx_tf_options_set_nhwc(migraphx_tf_options_t tf_options, b
migraphx_status
migraphx_tf_options_set_input_parameter_shape
(
migraphx_tf_options_t
tf_options
,
const
char
*
name
,
size_
t
*
dims
,
size_
t
dims_size
);
in
t
*
dims
,
in
t
dims_size
);
migraphx_status
migraphx_tf_options_set_default_dim_value
(
migraphx_tf_options_t
tf_options
,
size_t
value
);
migraphx_status
migraphx_tf_options_set_output_names
(
migraphx_tf_options_t
tf_options
,
const
char
**
names
,
size_
t
names_size
);
in
t
names_size
);
migraphx_status
migraphx_parse_tf
(
migraphx_program_t
*
out
,
const
char
*
name
,
migraphx_tf_options_t
options
);
...
...
src/api/include/migraphx/migraphx.hpp
View file @
94e3a2e4
...
...
@@ -37,7 +37,7 @@ void call(F f, Ts&&... xs)
throw
std
::
runtime_error
(
"Failed to call function"
);
}
template
<
class
F
,
class
Iterator
=
std
::
size_
t
>
template
<
class
F
,
class
Iterator
=
in
t
>
struct
iota_iterator
{
Iterator
index
;
...
...
@@ -230,14 +230,14 @@ struct shape : MIGRAPHX_CONST_HANDLE_BASE(shape)
/// Construct a shape with its type and lengths. The strides are
/// automatically computed assumming a packed layout.
shape
(
migraphx_shape_datatype_t
type
,
std
::
vector
<
size_
t
>
plengths
)
shape
(
migraphx_shape_datatype_t
type
,
std
::
vector
<
in
t
>
plengths
)
{
this
->
make_handle
(
&
migraphx_shape_create
,
type
,
plengths
.
data
(),
plengths
.
size
());
}
shape
(
migraphx_shape_datatype_t
type
,
std
::
vector
<
size_
t
>
plengths
,
std
::
vector
<
size_
t
>
pstrides
)
std
::
vector
<
in
t
>
plengths
,
std
::
vector
<
in
t
>
pstrides
)
{
this
->
make_handle
(
&
migraphx_shape_create_with_strides
,
type
,
...
...
@@ -247,18 +247,18 @@ struct shape : MIGRAPHX_CONST_HANDLE_BASE(shape)
pstrides
.
size
());
}
std
::
vector
<
size_
t
>
lengths
()
const
std
::
vector
<
in
t
>
lengths
()
const
{
const
size_
t
*
pout
;
size_
t
pout_size
;
const
in
t
*
pout
;
in
t
pout_size
;
call
(
&
migraphx_shape_lengths
,
&
pout
,
&
pout_size
,
this
->
get_handle_ptr
());
return
{
pout
,
pout
+
pout_size
};
}
std
::
vector
<
size_
t
>
strides
()
const
std
::
vector
<
in
t
>
strides
()
const
{
const
size_
t
*
pout
;
size_
t
pout_size
;
const
in
t
*
pout
;
in
t
pout_size
;
call
(
&
migraphx_shape_strides
,
&
pout
,
&
pout_size
,
this
->
get_handle_ptr
());
return
{
pout
,
pout
+
pout_size
};
}
...
...
@@ -270,9 +270,9 @@ struct shape : MIGRAPHX_CONST_HANDLE_BASE(shape)
return
pout
;
}
size_
t
bytes
()
const
in
t
bytes
()
const
{
size_
t
pout
;
in
t
pout
;
call
(
&
migraphx_shape_bytes
,
&
pout
,
this
->
get_handle_ptr
());
return
pout
;
}
...
...
@@ -323,7 +323,7 @@ struct argument : MIGRAPHX_CONST_HANDLE_BASE(argument)
}
/// Generate an argument using random data
static
argument
generate
(
shape
ps
,
size_
t
pseed
=
0
)
static
argument
generate
(
shape
ps
,
in
t
pseed
=
0
)
{
return
{
make
<
migraphx_argument
>
(
&
migraphx_argument_generate
,
ps
.
get_handle_ptr
(),
pseed
),
own
{}};
...
...
@@ -366,9 +366,9 @@ struct program_parameter_shapes : MIGRAPHX_HANDLE_BASE(program_parameter_shapes)
this
->
set_handle
(
p
,
borrow
{});
}
size_
t
size
()
const
in
t
size
()
const
{
size_
t
pout
;
in
t
pout
;
call
(
&
migraphx_program_parameter_shapes_size
,
&
pout
,
this
->
get_handle_ptr
());
return
pout
;
}
...
...
@@ -426,14 +426,14 @@ struct arguments : MIGRAPHX_HANDLE_BASE(arguments), array_base<arguments>
arguments
(
migraphx_arguments
*
p
,
borrow
)
{
this
->
set_handle
(
p
,
borrow
{});
}
size_
t
size
()
const
in
t
size
()
const
{
size_
t
pout
;
in
t
pout
;
call
(
&
migraphx_arguments_size
,
&
pout
,
this
->
get_handle_ptr
());
return
pout
;
}
argument
operator
[](
size_
t
pidx
)
const
argument
operator
[](
in
t
pidx
)
const
{
const_migraphx_argument_t
pout
;
call
(
&
migraphx_arguments_get
,
&
pout
,
this
->
get_handle_ptr
(),
pidx
);
...
...
@@ -443,7 +443,7 @@ struct arguments : MIGRAPHX_HANDLE_BASE(arguments), array_base<arguments>
struct
iterator_read
{
migraphx_arguments
*
self
;
argument
operator
()(
size_
t
pidx
)
const
argument
operator
()(
in
t
pidx
)
const
{
const_migraphx_argument_t
pout
;
call
(
&
migraphx_arguments_get
,
&
pout
,
self
,
pidx
);
...
...
@@ -459,14 +459,14 @@ struct shapes : MIGRAPHX_HANDLE_BASE(shapes), array_base<shapes>
shapes
(
migraphx_shapes
*
p
,
borrow
)
{
this
->
set_handle
(
p
,
borrow
{});
}
size_
t
size
()
const
in
t
size
()
const
{
size_
t
pout
;
in
t
pout
;
call
(
&
migraphx_shapes_size
,
&
pout
,
this
->
get_handle_ptr
());
return
pout
;
}
shape
operator
[](
size_
t
pidx
)
const
shape
operator
[](
in
t
pidx
)
const
{
const_migraphx_shape_t
pout
;
call
(
&
migraphx_shapes_get
,
&
pout
,
this
->
get_handle_ptr
(),
pidx
);
...
...
@@ -476,7 +476,7 @@ struct shapes : MIGRAPHX_HANDLE_BASE(shapes), array_base<shapes>
struct
iterator_read
{
migraphx_shapes
*
self
;
shape
operator
()(
size_
t
pidx
)
const
shape
operator
()(
in
t
pidx
)
const
{
const_migraphx_shape_t
pout
;
call
(
&
migraphx_shapes_get
,
&
pout
,
self
,
pidx
);
...
...
@@ -661,7 +661,7 @@ struct onnx_options : MIGRAPHX_HANDLE_BASE(onnx_options)
onnx_options
(
migraphx_onnx_options
*
p
,
own
)
{
this
->
set_handle
(
p
,
own
{});
}
/// Make onnx parser treat an inputs with a certain dimensions
void
set_input_parameter_shape
(
const
std
::
string
&
name
,
std
::
vector
<
std
::
size_
t
>
dim
)
void
set_input_parameter_shape
(
const
std
::
string
&
name
,
std
::
vector
<
in
t
>
dim
)
{
call
(
&
migraphx_onnx_options_set_input_parameter_shape
,
this
->
get_handle_ptr
(),
...
...
@@ -700,7 +700,7 @@ inline program parse_onnx(const char* filename)
/// Parse a buffer of memory as an onnx file
inline
program
parse_onnx_buffer
(
const
void
*
data
,
size_
t
size
,
const
migraphx
::
onnx_options
&
options
)
parse_onnx_buffer
(
const
void
*
data
,
in
t
size
,
const
migraphx
::
onnx_options
&
options
)
{
return
program
(
make
<
migraphx_program
>
(
&
migraphx_parse_onnx_buffer
,
data
,
size
,
options
.
get_handle_ptr
()),
...
...
@@ -708,7 +708,7 @@ parse_onnx_buffer(const void* data, size_t size, const migraphx::onnx_options& o
}
/// Parse a buffer of memory as an onnx file
inline
program
parse_onnx_buffer
(
const
void
*
data
,
size_
t
size
)
inline
program
parse_onnx_buffer
(
const
void
*
data
,
in
t
size
)
{
migraphx
::
onnx_options
options
;
return
program
(
...
...
@@ -743,7 +743,7 @@ struct tf_options : MIGRAPHX_HANDLE_BASE(tf_options)
tf_options
(
migraphx_tf_options
*
p
,
own
)
{
this
->
set_handle
(
p
,
own
{});
}
/// Make tf parser treat an inputs with a certain dimensions
void
set_input_parameter_shape
(
const
std
::
string
&
name
,
std
::
vector
<
std
::
size_
t
>
dim
)
void
set_input_parameter_shape
(
const
std
::
string
&
name
,
std
::
vector
<
in
t
>
dim
)
{
call
(
&
migraphx_tf_options_set_input_parameter_shape
,
this
->
get_handle_ptr
(),
...
...
src/argument.cpp
View file @
94e3a2e4
...
...
@@ -27,10 +27,10 @@ void argument::assign_buffer(std::function<char*()> d)
return
;
}
// Collect all shapes
std
::
unordered_map
<
std
::
size_
t
,
shape
>
shapes
;
std
::
unordered_map
<
in
t
,
shape
>
shapes
;
{
// cppcheck-suppress variableScope
std
::
size_
t
i
=
0
;
in
t
i
=
0
;
fix
([
&
](
auto
self
,
auto
ss
)
{
if
(
ss
.
sub_shapes
().
empty
())
{
...
...
@@ -45,14 +45,14 @@ void argument::assign_buffer(std::function<char*()> d)
})(
s
);
}
// Sort by type size
std
::
vector
<
std
::
size_
t
>
order
(
shapes
.
size
());
std
::
vector
<
in
t
>
order
(
shapes
.
size
());
std
::
iota
(
order
.
begin
(),
order
.
end
(),
0
);
std
::
sort
(
order
.
begin
(),
order
.
end
(),
by
(
std
::
greater
<>
{},
[
&
](
auto
i
)
{
return
shapes
[
i
].
type_size
();
}));
// Compute offsets
std
::
unordered_map
<
std
::
size_t
,
std
::
size_
t
>
offsets
;
std
::
size_
t
offset
=
0
;
std
::
unordered_map
<
int
,
in
t
>
offsets
;
in
t
offset
=
0
;
for
(
auto
i
:
order
)
{
offsets
[
i
]
=
offset
;
...
...
@@ -61,7 +61,7 @@ void argument::assign_buffer(std::function<char*()> d)
assert
(
offset
==
s
.
bytes
());
// cppcheck-suppress variableScope
std
::
size_
t
i
=
0
;
in
t
i
=
0
;
m_data
=
fix
<
data_t
>
([
&
](
auto
self
,
auto
ss
)
{
data_t
result
;
if
(
ss
.
sub_shapes
().
empty
())
...
...
@@ -155,7 +155,7 @@ std::vector<argument> argument::get_sub_objects() const
return
result
;
}
argument
argument
::
element
(
std
::
size_
t
i
)
const
argument
argument
::
element
(
in
t
i
)
const
{
assert
(
this
->
get_shape
().
sub_shapes
().
empty
());
auto
idx
=
this
->
get_shape
().
index
(
i
);
...
...
src/cpp_generator.cpp
View file @
94e3a2e4
...
...
@@ -86,7 +86,7 @@ cpp_generator::function& cpp_generator::function::set_generic_types(const module
struct
cpp_generator_impl
{
std
::
stringstream
fs
{};
std
::
size_
t
function_count
=
0
;
in
t
function_count
=
0
;
std
::
function
<
std
::
string
(
std
::
string
)
>
fmap
=
nullptr
;
std
::
function
<
std
::
string
(
shape
)
>
fresult
=
nullptr
;
std
::
unordered_map
<
std
::
string
,
std
::
string
>
point_op_map
=
{};
...
...
src/dead_code_elimination.cpp
View file @
94e3a2e4
...
...
@@ -14,7 +14,7 @@ std::ptrdiff_t bidistance(const Range& r, Iterator start, Iterator last)
{
auto
start_forward
=
start
;
auto
start_backwards
=
start
;
std
::
size_
t
n
=
0
;
in
t
n
=
0
;
while
(
start_forward
!=
last
and
start_backwards
!=
last
)
{
n
++
;
...
...
src/driver/alexnet.cpp
View file @
94e3a2e4
...
...
@@ -8,7 +8,7 @@ namespace migraphx {
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
migraphx
::
program
alexnet
(
unsigned
batch
)
// NOLINT(readability-function-size)
migraphx
::
program
alexnet
(
int
batch
)
// NOLINT(readability-function-size)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
src/driver/inceptionv3.cpp
View file @
94e3a2e4
...
...
@@ -8,7 +8,7 @@ namespace migraphx {
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
migraphx
::
program
inceptionv3
(
unsigned
batch
)
// NOLINT(readability-function-size)
migraphx
::
program
inceptionv3
(
int
batch
)
// NOLINT(readability-function-size)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
src/driver/main.cpp
View file @
94e3a2e4
...
...
@@ -37,7 +37,7 @@ struct loader
std
::
string
model
;
std
::
string
file
;
std
::
string
file_type
;
unsigned
batch
=
1
;
int
batch
=
1
;
bool
is_nhwc
=
true
;
unsigned
trim
=
0
;
bool
optimize
=
false
;
...
...
@@ -99,7 +99,7 @@ struct loader
static
auto
parse_param_dims
(
const
std
::
vector
<
std
::
string
>&
param_dims_info
)
{
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
std
::
size_
t
>>
map_input_dims
;
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
in
t
>>
map_input_dims
;
std
::
string
name
=
""
;
for
(
auto
&&
x
:
param_dims_info
)
{
...
...
@@ -109,7 +109,7 @@ struct loader
}
else
{
map_input_dims
[
name
].
push_back
(
value_parser
<
std
::
size_
t
>::
apply
(
x
));
map_input_dims
[
name
].
push_back
(
value_parser
<
in
t
>::
apply
(
x
));
}
}
...
...
src/driver/models.hpp
View file @
94e3a2e4
...
...
@@ -5,9 +5,9 @@ namespace migraphx {
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
migraphx
::
program
resnet50
(
unsigned
batch
);
migraphx
::
program
inceptionv3
(
unsigned
batch
);
migraphx
::
program
alexnet
(
unsigned
batch
);
migraphx
::
program
resnet50
(
int
batch
);
migraphx
::
program
inceptionv3
(
int
batch
);
migraphx
::
program
alexnet
(
int
batch
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace driver
...
...
src/driver/resnet50.cpp
View file @
94e3a2e4
...
...
@@ -8,7 +8,7 @@ namespace migraphx {
namespace
driver
{
inline
namespace
MIGRAPHX_INLINE_NS
{
migraphx
::
program
resnet50
(
unsigned
batch
)
// NOLINT(readability-function-size)
migraphx
::
program
resnet50
(
int
batch
)
// NOLINT(readability-function-size)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
src/driver/verify.cpp
View file @
94e3a2e4
...
...
@@ -58,8 +58,8 @@ void verify_program(const std::string& name,
auto
x
=
run_ref
(
p
,
inputs
);
auto
y
=
run_target
(
p
,
t
,
options
,
quantize
,
inputs
);
std
::
size_
t
output_num
=
x
.
size
();
for
(
std
::
size_
t
i
=
0
;
i
<
output_num
;
++
i
)
in
t
output_num
=
x
.
size
();
for
(
in
t
i
=
0
;
i
<
output_num
;
++
i
)
{
verify_args
(
name
,
x
[
i
],
y
[
i
],
tolerance
);
}
...
...
@@ -136,7 +136,7 @@ void verify_reduced_program(const program& p,
{
const
auto
*
mm
=
p
.
get_main_module
();
auto
n
=
std
::
distance
(
mm
->
begin
(),
mm
->
end
());
for
(
std
::
size_
t
i
=
0
;
i
<
n
;
i
++
)
for
(
in
t
i
=
0
;
i
<
n
;
i
++
)
{
verify_reduced
(
p
,
i
,
t
,
options
,
quantize
,
inputs
,
tolerance
);
}
...
...
src/dynamic_loader.cpp
View file @
94e3a2e4
...
...
@@ -17,7 +17,7 @@ struct dynamic_loader_impl
{
}
static
std
::
shared_ptr
<
dynamic_loader_impl
>
from_buffer
(
const
char
*
image
,
std
::
size_
t
size
)
static
std
::
shared_ptr
<
dynamic_loader_impl
>
from_buffer
(
const
char
*
image
,
in
t
size
)
{
auto
t
=
std
::
make_shared
<
tmp_dir
>
(
"dloader"
);
auto
f
=
t
->
path
/
"libtmp.so"
;
...
...
@@ -33,7 +33,7 @@ dynamic_loader::dynamic_loader(const fs::path& p) : impl(std::make_shared<dynami
{
}
dynamic_loader
::
dynamic_loader
(
const
char
*
image
,
std
::
size_
t
size
)
dynamic_loader
::
dynamic_loader
(
const
char
*
image
,
in
t
size
)
:
impl
(
dynamic_loader_impl
::
from_buffer
(
image
,
size
))
{
}
...
...
src/eliminate_allocation.cpp
View file @
94e3a2e4
...
...
@@ -24,8 +24,8 @@ void eliminate_allocation::apply(module& p) const
if
(
ins
->
name
()
!=
allocation_op
)
continue
;
allocs
.
emplace_back
(
ins
,
n
);
std
::
size_
t
size
=
ins
->
get_shape
().
bytes
();
std
::
size_
t
padding
=
(
alignment
-
(
size
%
alignment
))
%
alignment
;
in
t
size
=
ins
->
get_shape
().
bytes
();
in
t
padding
=
(
alignment
-
(
size
%
alignment
))
%
alignment
;
n
+=
size
+
padding
;
}
if
(
n
>
0
)
...
...
src/eliminate_pad.cpp
View file @
94e3a2e4
...
...
@@ -19,19 +19,19 @@ static void update_op(const instruction_ref& input, const instruction_ref& ins,
auto
kdims
=
input
->
get_shape
().
lens
().
size
()
-
2
;
auto
kdims_it
=
pad_op
.
pads
.
begin
()
+
2
;
std
::
vector
<
size_
t
>
pads_l
(
kdims_it
,
kdims_it
+
kdims
);
std
::
vector
<
size_
t
>
pads_r
(
kdims_it
+
kdims
+
2
,
pad_op
.
pads
.
end
());
std
::
vector
<
in
t
>
pads_l
(
kdims_it
,
kdims_it
+
kdims
);
std
::
vector
<
in
t
>
pads_r
(
kdims_it
+
kdims
+
2
,
pad_op
.
pads
.
end
());
auto
op
=
ins
->
get_operator
();
std
::
vector
<
size_
t
>
padding
(
kdims
*
2
,
0
);
std
::
vector
<
in
t
>
padding
(
kdims
*
2
,
0
);
std
::
transform
(
pads_l
.
begin
(),
pads_l
.
end
(),
padding
.
begin
(),
padding
.
begin
(),
std
::
plus
<
size_
t
>
());
pads_l
.
begin
(),
pads_l
.
end
(),
padding
.
begin
(),
padding
.
begin
(),
std
::
plus
<
in
t
>
());
std
::
transform
(
pads_r
.
begin
(),
pads_r
.
end
(),
padding
.
begin
()
+
kdims
,
padding
.
begin
()
+
kdims
,
std
::
plus
<
size_
t
>
());
std
::
plus
<
in
t
>
());
op
.
from_value
({{
"padding"
,
padding
}});
...
...
@@ -53,16 +53,16 @@ static void update_pooling(const instruction_ref& input, const instruction_ref&
auto
kdims
=
input
->
get_shape
().
lens
().
size
()
-
2
;
auto
kdims_it
=
pad_op
.
pads
.
begin
()
+
2
;
std
::
vector
<
size_
t
>
pads_l
(
kdims_it
,
kdims_it
+
kdims
);
std
::
vector
<
size_
t
>
pads_r
(
kdims_it
+
kdims
+
2
,
pad_op
.
pads
.
end
());
std
::
vector
<
in
t
>
pads_l
(
kdims_it
,
kdims_it
+
kdims
);
std
::
vector
<
in
t
>
pads_r
(
kdims_it
+
kdims
+
2
,
pad_op
.
pads
.
end
());
std
::
transform
(
pads_l
.
begin
(),
pads_l
.
end
(),
op
.
padding
.
begin
(),
op
.
padding
.
begin
(),
std
::
plus
<
size_
t
>
());
pads_l
.
begin
(),
pads_l
.
end
(),
op
.
padding
.
begin
(),
op
.
padding
.
begin
(),
std
::
plus
<
in
t
>
());
std
::
transform
(
pads_r
.
begin
(),
pads_r
.
end
(),
op
.
padding
.
begin
()
+
kdims
,
op
.
padding
.
begin
()
+
kdims
,
std
::
plus
<
size_
t
>
());
std
::
plus
<
in
t
>
());
std
::
vector
<
instruction_ref
>
new_inputs
{
ins
->
inputs
()};
new_inputs
.
front
()
=
input
->
inputs
().
front
();
...
...
src/env.cpp
View file @
94e3a2e4
...
...
@@ -21,7 +21,7 @@ bool disabled(const char* name)
return
contains
({
"0"
,
"disable"
,
"disabled"
,
"no"
,
"false"
},
e
.
front
());
}
std
::
size_
t
value_of
(
const
char
*
name
,
std
::
size_
t
fallback
)
in
t
value_of
(
const
char
*
name
,
in
t
fallback
)
{
auto
e
=
env
(
name
);
if
(
e
.
empty
())
...
...
src/file_buffer.cpp
View file @
94e3a2e4
...
...
@@ -31,7 +31,7 @@ std::string read_string(const std::string& filename)
return
generic_read_file
<
std
::
string
>
(
filename
);
}
void
write_buffer
(
const
std
::
string
&
filename
,
const
char
*
buffer
,
std
::
size_
t
size
)
void
write_buffer
(
const
std
::
string
&
filename
,
const
char
*
buffer
,
in
t
size
)
{
std
::
ofstream
os
(
filename
);
os
.
write
(
buffer
,
size
);
...
...
src/files
0 → 100644
View file @
94e3a2e4
This diff is collapsed.
Click to expand it.
src/fuse_pointwise.cpp
View file @
94e3a2e4
...
...
@@ -28,7 +28,7 @@ static literal get_scalar(instruction_ref ins)
static
void
create_pointwise_modules
(
module_pass_manager
&
mpm
)
{
std
::
size_
t
n
=
0
;
in
t
n
=
0
;
for
(
auto
ins
:
iterator_for
(
mpm
.
get_module
()))
{
if
(
not
ins
->
get_operator
().
attributes
().
get
(
"pointwise"
,
false
))
...
...
@@ -39,7 +39,7 @@ static void create_pointwise_modules(module_pass_manager& mpm)
std
::
unordered_map
<
instruction_ref
,
instruction_ref
>
param_map
;
std
::
vector
<
instruction_ref
>
pointwise_inputs
;
std
::
size_
t
i
=
0
;
in
t
i
=
0
;
for
(
auto
input
:
ins
->
inputs
())
{
if
(
contains
(
param_map
,
input
))
...
...
Prev
1
2
3
4
5
…
13
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