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
65c5581f
Unverified
Commit
65c5581f
authored
Nov 14, 2018
by
Paul Fultz II
Committed by
GitHub
Nov 14, 2018
Browse files
Merge branch 'master' into identity
parents
453fa37a
f04a3ba6
Changes
192
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
142 additions
and
142 deletions
+142
-142
test/program_test.cpp
test/program_test.cpp
+9
-9
test/shape_test.cpp
test/shape_test.cpp
+18
-18
test/simplify_algebra_test.cpp
test/simplify_algebra_test.cpp
+52
-52
test/simplify_reshapes_test.cpp
test/simplify_reshapes_test.cpp
+25
-25
test/type_name.cpp
test/type_name.cpp
+5
-5
test/validate.cpp
test/validate.cpp
+10
-10
tools/generate.sh
tools/generate.sh
+1
-1
tools/include/concat_opt.hpp
tools/include/concat_opt.hpp
+4
-4
tools/include/context.hpp
tools/include/context.hpp
+2
-2
tools/include/operation.hpp
tools/include/operation.hpp
+10
-10
tools/include/pass.hpp
tools/include/pass.hpp
+2
-2
tools/include/target.hpp
tools/include/target.hpp
+4
-4
No files found.
test/program_test.cpp
View file @
65c5581f
#include <migraph/program.hpp>
#include <migraph/iterator_for.hpp>
#include <migraph/instruction.hpp>
#include <migraph
x
/program.hpp>
#include <migraph
x
/iterator_for.hpp>
#include <migraph
x
/instruction.hpp>
#include <sstream>
#include "test.hpp"
#include <basic_ops.hpp>
migraph
::
program
create_program
()
migraph
x
::
program
create_program
()
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int64_type
});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int64_type
});
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int64_type
});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraph
x
::
shape
::
int64_type
});
auto
sum
=
p
.
add_instruction
(
sum_op
{},
x
,
y
);
auto
one
=
p
.
add_literal
(
1
);
...
...
@@ -22,8 +22,8 @@ migraph::program create_program()
TEST_CASE
(
program_equality
)
{
migraph
::
program
x
=
create_program
();
migraph
::
program
y
=
create_program
();
migraph
x
::
program
x
=
create_program
();
migraph
x
::
program
y
=
create_program
();
EXPECT
(
x
==
y
);
}
...
...
test/shape_test.cpp
View file @
65c5581f
#include <migraph/shape.hpp>
#include <migraph
x
/shape.hpp>
#include <array>
#include <algorithm>
#include <numeric>
...
...
@@ -7,22 +7,22 @@
TEST_CASE
(
test_shape_default
)
{
migraph
::
shape
s
{};
migraph
x
::
shape
s
{};
EXPECT
(
s
.
elements
()
==
0
);
EXPECT
(
s
.
bytes
()
==
0
);
}
TEST_CASE
(
test_shape_assign
)
{
migraph
::
shape
s1
{
migraph
::
shape
::
float_type
,
{
100
,
32
,
8
,
8
}};
migraph
::
shape
s2
=
s1
;
// NOLINT
migraph
x
::
shape
s1
{
migraph
x
::
shape
::
float_type
,
{
100
,
32
,
8
,
8
}};
migraph
x
::
shape
s2
=
s1
;
// NOLINT
EXPECT
(
s1
==
s2
);
EXPECT
(
!
(
s1
!=
s2
));
}
TEST_CASE
(
test_shape_packed_default
)
{
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
2
,
2
}};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
{
2
,
2
}};
EXPECT
(
s
.
standard
());
EXPECT
(
s
.
packed
());
EXPECT
(
not
s
.
transposed
());
...
...
@@ -31,7 +31,7 @@ TEST_CASE(test_shape_packed_default)
TEST_CASE
(
test_shape_packed
)
{
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
2
,
2
},
{
2
,
1
}};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
{
2
,
2
},
{
2
,
1
}};
EXPECT
(
s
.
standard
());
EXPECT
(
s
.
packed
());
EXPECT
(
not
s
.
transposed
());
...
...
@@ -40,7 +40,7 @@ TEST_CASE(test_shape_packed)
TEST_CASE
(
test_shape_transposed
)
{
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
2
,
2
},
{
1
,
2
}};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
{
2
,
2
},
{
1
,
2
}};
EXPECT
(
not
s
.
standard
());
EXPECT
(
s
.
packed
());
EXPECT
(
s
.
transposed
());
...
...
@@ -49,7 +49,7 @@ TEST_CASE(test_shape_transposed)
TEST_CASE
(
test_shape_broadcasted
)
{
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
2
,
2
},
{
1
,
0
}};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
{
2
,
2
},
{
1
,
0
}};
EXPECT
(
not
s
.
standard
());
EXPECT
(
not
s
.
packed
());
EXPECT
(
not
s
.
transposed
());
...
...
@@ -58,20 +58,20 @@ TEST_CASE(test_shape_broadcasted)
TEST_CASE
(
test_shape_default_copy
)
{
migraph
::
shape
s1
{};
migraph
::
shape
s2
{};
migraph
x
::
shape
s1
{};
migraph
x
::
shape
s2
{};
EXPECT
(
s1
==
s2
);
EXPECT
(
!
(
s1
!=
s2
));
}
TEST_CASE
(
test_shape4
)
{
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
100
,
32
,
8
,
8
}};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
{
100
,
32
,
8
,
8
}};
EXPECT
(
s
.
standard
());
EXPECT
(
s
.
packed
());
EXPECT
(
not
s
.
transposed
());
EXPECT
(
not
s
.
broadcasted
());
EXPECT
(
s
.
type
()
==
migraph
::
shape
::
float_type
);
EXPECT
(
s
.
type
()
==
migraph
x
::
shape
::
float_type
);
EXPECT
(
s
.
lens
()[
0
]
==
100
);
EXPECT
(
s
.
lens
()[
1
]
==
32
);
EXPECT
(
s
.
lens
()[
2
]
==
8
);
...
...
@@ -99,12 +99,12 @@ TEST_CASE(test_shape4)
TEST_CASE
(
test_shape42
)
{
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
100
,
32
,
8
,
8
},
{
2048
,
64
,
8
,
1
}};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
{
100
,
32
,
8
,
8
},
{
2048
,
64
,
8
,
1
}};
EXPECT
(
s
.
standard
());
EXPECT
(
s
.
packed
());
EXPECT
(
not
s
.
transposed
());
EXPECT
(
not
s
.
broadcasted
());
EXPECT
(
s
.
type
()
==
migraph
::
shape
::
float_type
);
EXPECT
(
s
.
type
()
==
migraph
x
::
shape
::
float_type
);
EXPECT
(
s
.
lens
()[
0
]
==
100
);
EXPECT
(
s
.
lens
()[
1
]
==
32
);
EXPECT
(
s
.
lens
()[
2
]
==
8
);
...
...
@@ -132,12 +132,12 @@ TEST_CASE(test_shape42)
TEST_CASE
(
test_shape4_transposed
)
{
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
{
32
,
100
,
8
,
8
},
{
64
,
2048
,
8
,
1
}};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
{
32
,
100
,
8
,
8
},
{
64
,
2048
,
8
,
1
}};
EXPECT
(
s
.
transposed
());
EXPECT
(
s
.
packed
());
EXPECT
(
not
s
.
standard
());
EXPECT
(
not
s
.
broadcasted
());
EXPECT
(
s
.
type
()
==
migraph
::
shape
::
float_type
);
EXPECT
(
s
.
type
()
==
migraph
x
::
shape
::
float_type
);
EXPECT
(
s
.
lens
()[
0
]
==
32
);
EXPECT
(
s
.
lens
()[
1
]
==
100
);
EXPECT
(
s
.
lens
()[
2
]
==
8
);
...
...
@@ -179,12 +179,12 @@ TEST_CASE(test_shape4_nonpacked)
strides
.
rbegin
()
+
1
,
std
::
multiplies
<
std
::
size_t
>
());
migraph
::
shape
s
{
migraph
::
shape
::
float_type
,
lens
,
strides
};
migraph
x
::
shape
s
{
migraph
x
::
shape
::
float_type
,
lens
,
strides
};
EXPECT
(
not
s
.
standard
());
EXPECT
(
not
s
.
packed
());
EXPECT
(
not
s
.
transposed
());
EXPECT
(
not
s
.
broadcasted
());
EXPECT
(
s
.
type
()
==
migraph
::
shape
::
float_type
);
EXPECT
(
s
.
type
()
==
migraph
x
::
shape
::
float_type
);
EXPECT
(
s
.
lens
()[
0
]
==
100
);
EXPECT
(
s
.
lens
()[
1
]
==
32
);
EXPECT
(
s
.
lens
()[
2
]
==
8
);
...
...
test/simplify_algebra_test.cpp
View file @
65c5581f
#include <migraph/simplify_algebra.hpp>
#include <migraph/dead_code_elimination.hpp>
#include <migraph/operators.hpp>
#include <migraph
x
/simplify_algebra.hpp>
#include <migraph
x
/dead_code_elimination.hpp>
#include <migraph
x
/operators.hpp>
#include <basic_ops.hpp>
#include <test.hpp>
struct
simplify_algebra_target
{
std
::
string
name
()
const
{
return
"simplify_algebra"
;
}
std
::
vector
<
migraph
::
pass
>
get_passes
(
migraph
::
context
&
)
const
std
::
vector
<
migraph
x
::
pass
>
get_passes
(
migraph
x
::
context
&
)
const
{
return
{
migraph
::
simplify_algebra
{},
migraph
::
dead_code_elimination
{}};
return
{
migraph
x
::
simplify_algebra
{},
migraph
x
::
dead_code_elimination
{}};
}
migraph
::
context
get_context
()
const
{
return
{};
}
migraph
x
::
context
get_context
()
const
{
return
{};
}
};
TEST_CASE
(
simplify_add1
)
{
migraph
::
program
p1
;
migraph
x
::
program
p1
;
{
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p1
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p1
.
add_parameter
(
"y"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p1
.
add_literal
(
1
);
auto
two
=
p1
.
add_literal
(
2
);
auto
sum1
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
x
,
one
);
auto
sum2
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
y
,
two
);
auto
sum3
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
sum1
,
sum2
);
auto
sum1
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
x
,
one
);
auto
sum2
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
y
,
two
);
auto
sum3
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum1
,
sum2
);
p1
.
add_instruction
(
pass_op
{},
sum3
);
}
p1
.
compile
(
simplify_algebra_target
{});
migraph
::
program
p2
;
migraph
x
::
program
p2
;
{
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p2
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p2
.
add_parameter
(
"y"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p2
.
add_literal
(
1
);
auto
two
=
p2
.
add_literal
(
2
);
auto
sum1
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
two
);
auto
sum2
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
x
,
y
);
auto
sum3
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
sum2
,
sum1
);
auto
sum1
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
two
);
auto
sum2
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
x
,
y
);
auto
sum3
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum2
,
sum1
);
p2
.
add_instruction
(
pass_op
{},
sum3
);
}
EXPECT
(
p1
==
p2
);
...
...
@@ -45,28 +45,28 @@ TEST_CASE(simplify_add1)
TEST_CASE
(
simplify_add2
)
{
migraph
::
program
p1
;
migraph
x
::
program
p1
;
{
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p1
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p1
.
add_parameter
(
"y"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p1
.
add_literal
(
1
);
auto
two
=
p1
.
add_literal
(
2
);
auto
sum1
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
two
,
y
);
auto
sum3
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
sum1
,
sum2
);
auto
sum1
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
two
,
y
);
auto
sum3
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum1
,
sum2
);
p1
.
add_instruction
(
pass_op
{},
sum3
);
}
p1
.
compile
(
simplify_algebra_target
{});
migraph
::
program
p2
;
migraph
x
::
program
p2
;
{
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p2
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p2
.
add_parameter
(
"y"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p2
.
add_literal
(
1
);
auto
two
=
p2
.
add_literal
(
2
);
auto
sum1
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
two
);
auto
sum2
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
x
,
y
);
auto
sum3
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
sum2
,
sum1
);
auto
sum1
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
two
);
auto
sum2
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
x
,
y
);
auto
sum3
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum2
,
sum1
);
p2
.
add_instruction
(
pass_op
{},
sum3
);
}
EXPECT
(
p1
==
p2
);
...
...
@@ -74,26 +74,26 @@ TEST_CASE(simplify_add2)
TEST_CASE
(
simplify_add3
)
{
migraph
::
program
p1
;
migraph
x
::
program
p1
;
{
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p1
.
add_literal
(
1
);
auto
two
=
p1
.
add_literal
(
2
);
auto
sum1
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
two
);
auto
sum3
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
sum1
,
sum2
);
auto
sum1
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
two
);
auto
sum3
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum1
,
sum2
);
p1
.
add_instruction
(
pass_op
{},
sum3
);
}
p1
.
compile
(
simplify_algebra_target
{});
migraph
::
program
p2
;
migraph
x
::
program
p2
;
{
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p2
.
add_literal
(
1
);
auto
two
=
p2
.
add_literal
(
2
);
auto
sum1
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
two
);
auto
sum3
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
sum1
,
sum2
);
auto
sum1
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
two
);
auto
sum3
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum1
,
sum2
);
p2
.
add_instruction
(
pass_op
{},
sum3
);
}
EXPECT
(
p1
==
p2
);
...
...
@@ -102,28 +102,28 @@ TEST_CASE(simplify_add3)
// TODO: Add test case
void
simplify_add4
()
{
migraph
::
program
p1
;
migraph
x
::
program
p1
;
{
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p1
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p1
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p1
.
add_parameter
(
"y"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p1
.
add_literal
(
1
);
auto
two
=
p1
.
add_literal
(
2
);
auto
sum1
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
sum1
,
y
);
auto
sum3
=
p1
.
add_instruction
(
migraph
::
op
::
add
{},
sum2
,
two
);
auto
sum1
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
x
);
auto
sum2
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum1
,
y
);
auto
sum3
=
p1
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum2
,
two
);
p1
.
add_instruction
(
pass_op
{},
sum3
);
}
p1
.
compile
(
simplify_algebra_target
{});
migraph
::
program
p2
;
migraph
x
::
program
p2
;
{
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p2
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int32_type
,
{
1
}});
auto
x
=
p2
.
add_parameter
(
"x"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
y
=
p2
.
add_parameter
(
"y"
,
{
migraph
x
::
shape
::
int32_type
,
{
1
}});
auto
one
=
p2
.
add_literal
(
1
);
auto
two
=
p2
.
add_literal
(
2
);
auto
sum1
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
one
,
two
);
auto
sum2
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
x
,
y
);
auto
sum3
=
p2
.
add_instruction
(
migraph
::
op
::
add
{},
sum2
,
sum1
);
auto
sum1
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
one
,
two
);
auto
sum2
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
x
,
y
);
auto
sum3
=
p2
.
add_instruction
(
migraph
x
::
op
::
add
{},
sum2
,
sum1
);
p2
.
add_instruction
(
pass_op
{},
sum3
);
}
EXPECT
(
p1
==
p2
);
...
...
test/simplify_reshapes_test.cpp
View file @
65c5581f
#include <migraph/simplify_reshapes.hpp>
#include <migraph/dead_code_elimination.hpp>
#include <migraph/operators.hpp>
#include <migraph
x
/simplify_reshapes.hpp>
#include <migraph
x
/dead_code_elimination.hpp>
#include <migraph
x
/operators.hpp>
#include <basic_ops.hpp>
#include <test.hpp>
struct
simplify_reshapes_target
{
std
::
string
name
()
const
{
return
"simplify_reshapes"
;
}
std
::
vector
<
migraph
::
pass
>
get_passes
(
migraph
::
context
&
)
const
std
::
vector
<
migraph
x
::
pass
>
get_passes
(
migraph
x
::
context
&
)
const
{
return
{
migraph
::
simplify_reshapes
{},
migraph
::
dead_code_elimination
{}};
return
{
migraph
x
::
simplify_reshapes
{},
migraph
x
::
dead_code_elimination
{}};
}
migraph
::
context
get_context
()
const
{
return
{};
}
migraph
x
::
context
get_context
()
const
{
return
{};
}
};
TEST_CASE
(
double_contig
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
l
=
p
.
add_literal
(
get_2x2
());
auto
t1
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
c1
=
p
.
add_instruction
(
migraph
::
op
::
contiguous
{},
t1
);
auto
c2
=
p
.
add_instruction
(
migraph
::
op
::
contiguous
{},
c1
);
auto
t1
=
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
c1
=
p
.
add_instruction
(
migraph
x
::
op
::
contiguous
{},
t1
);
auto
c2
=
p
.
add_instruction
(
migraph
x
::
op
::
contiguous
{},
c1
);
p
.
add_instruction
(
pass_op
{},
c2
);
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
...
...
@@ -34,10 +34,10 @@ TEST_CASE(double_contig)
TEST_CASE
(
double_transpose
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
l
=
p
.
add_literal
(
get_2x2
());
auto
t1
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
t2
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
t1
);
auto
t1
=
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
t2
=
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
t1
);
p
.
add_instruction
(
pass_op
{},
t2
);
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
...
...
@@ -51,12 +51,12 @@ TEST_CASE(double_transpose)
TEST_CASE
(
double_transpose_contig
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
l
=
p
.
add_literal
(
get_2x2
());
auto
t1
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
c1
=
p
.
add_instruction
(
migraph
::
op
::
contiguous
{},
t1
);
auto
t2
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
c1
);
auto
c2
=
p
.
add_instruction
(
migraph
::
op
::
contiguous
{},
t2
);
auto
t1
=
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
c1
=
p
.
add_instruction
(
migraph
x
::
op
::
contiguous
{},
t1
);
auto
t2
=
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
c1
);
auto
c2
=
p
.
add_instruction
(
migraph
x
::
op
::
contiguous
{},
t2
);
p
.
add_instruction
(
pass_op
{},
c2
);
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
...
...
@@ -70,9 +70,9 @@ TEST_CASE(double_transpose_contig)
TEST_CASE
(
single_transpose
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
l
=
p
.
add_literal
(
get_2x2
());
auto
t1
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
l
);
auto
t1
=
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
l
);
p
.
add_instruction
(
pass_op
{},
t1
);
EXPECT
(
not
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
transposed
());
...
...
@@ -86,10 +86,10 @@ TEST_CASE(single_transpose)
TEST_CASE
(
double_transpose_sin_pass
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
l
=
p
.
add_literal
(
get_2x2
());
auto
t1
=
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
l
);
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
t1
);
auto
t1
=
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
l
);
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
t1
);
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
p
.
compile
(
simplify_reshapes_target
{});
...
...
@@ -104,9 +104,9 @@ TEST_CASE(double_transpose_sin_pass)
TEST_CASE
(
single_transpose_sin_pass
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
l
=
p
.
add_literal
(
get_2x2
());
p
.
add_instruction
(
migraph
::
op
::
transpose
{{
1
,
0
}},
l
);
p
.
add_instruction
(
migraph
x
::
op
::
transpose
{{
1
,
0
}},
l
);
EXPECT
(
not
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
transposed
());
p
.
compile
(
simplify_reshapes_target
{});
...
...
test/type_name.cpp
View file @
65c5581f
#include <migraph/type_name.hpp>
#include <migraph
x
/type_name.hpp>
#include "test.hpp"
struct
global_class
...
...
@@ -21,8 +21,8 @@ struct ns_class
int
main
()
{
EXPECT
(
migraph
::
get_type_name
<
global_class
>
()
==
"global_class"
);
EXPECT
(
migraph
::
get_type_name
<
global_class
::
inner_class
>
()
==
"global_class::inner_class"
);
EXPECT
(
migraph
::
get_type_name
<
foo
::
ns_class
>
()
==
"foo::ns_class"
);
EXPECT
(
migraph
::
get_type_name
<
foo
::
ns_class
::
inner_class
>
()
==
"foo::ns_class::inner_class"
);
EXPECT
(
migraph
x
::
get_type_name
<
global_class
>
()
==
"global_class"
);
EXPECT
(
migraph
x
::
get_type_name
<
global_class
::
inner_class
>
()
==
"global_class::inner_class"
);
EXPECT
(
migraph
x
::
get_type_name
<
foo
::
ns_class
>
()
==
"foo::ns_class"
);
EXPECT
(
migraph
x
::
get_type_name
<
foo
::
ns_class
::
inner_class
>
()
==
"foo::ns_class::inner_class"
);
}
test/validate.cpp
View file @
65c5581f
#include <migraph/program.hpp>
#include <migraph/instruction.hpp>
#include <migraph
x
/program.hpp>
#include <migraph
x
/instruction.hpp>
#include <basic_ops.hpp>
#include <test.hpp>
#include <rob.hpp>
TEST_CASE
(
simple_test
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
p
.
add_instruction
(
sum_op
{},
one
,
two
);
EXPECT
(
bool
{
p
.
validate
()
==
p
.
end
()});
auto
result
=
p
.
eval
({});
EXPECT
(
result
==
migraph
::
literal
{
3
});
EXPECT
(
result
!=
migraph
::
literal
{
4
});
EXPECT
(
result
==
migraph
x
::
literal
{
3
});
EXPECT
(
result
!=
migraph
x
::
literal
{
4
});
}
TEST_CASE
(
out_of_order
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
...
...
@@ -30,7 +30,7 @@ TEST_CASE(out_of_order)
TEST_CASE
(
incomplete_args
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
...
...
@@ -40,13 +40,13 @@ TEST_CASE(incomplete_args)
}
MIGRAPH_ROB
(
access_ins_arguments
,
std
::
vector
<
migraph
::
instruction_ref
>
,
migraph
::
instruction
,
std
::
vector
<
migraph
x
::
instruction_ref
>
,
migraph
x
::
instruction
,
arguments
)
TEST_CASE
(
invalid_args
)
{
migraph
::
program
p
;
migraph
x
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
...
...
tools/generate.sh
View file @
65c5581f
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
ls
-1
$DIR
/include/ | xargs
-n
1
-P
$(
nproc
)
-I
{}
-t
bash
-c
"python3.6
$DIR
/te.py
$DIR
/include/{} | clang-format-5.0 -style=file >
$DIR
/../src/include/migraph/{}"
ls
-1
$DIR
/include/ | xargs
-n
1
-P
$(
nproc
)
-I
{}
-t
bash
-c
"python3.6
$DIR
/te.py
$DIR
/include/{} | clang-format-5.0 -style=file >
$DIR
/../src/include/migraph
x
/{}"
tools/include/concat_opt.hpp
View file @
65c5581f
...
...
@@ -8,10 +8,10 @@
#include <type_traits>
#include <utility>
#include <migraph/operation.hpp>
#include <migraph/operators.hpp>
#include <migraph
x
/operation.hpp>
#include <migraph
x
/operators.hpp>
namespace
migraph
{
namespace
migraph
x
{
struct
program
;
...
...
@@ -40,6 +40,6 @@ interface('concat_optimization',
#endif
}
// namespace migraph
}
// namespace migraph
x
#endif
tools/include/context.hpp
View file @
65c5581f
...
...
@@ -8,7 +8,7 @@
#include <type_traits>
#include <utility>
namespace
migraph
{
namespace
migraph
x
{
#ifdef DOXYGEN
...
...
@@ -31,6 +31,6 @@ interface('context',
#endif
}
// namespace migraph
}
// namespace migraph
x
#endif
tools/include/operation.hpp
View file @
65c5581f
...
...
@@ -7,14 +7,14 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <migraph/shape.hpp>
#include <migraph/reflect.hpp>
#include <migraph/streamutils.hpp>
#include <migraph/argument.hpp>
#include <migraph/context.hpp>
#include <migraph/auto_any_cast.hpp>
#include <migraph
x
/shape.hpp>
#include <migraph
x
/reflect.hpp>
#include <migraph
x
/streamutils.hpp>
#include <migraph
x
/argument.hpp>
#include <migraph
x
/context.hpp>
#include <migraph
x
/auto_any_cast.hpp>
namespace
migraph
{
namespace
migraph
x
{
#ifdef DOXYGEN
...
...
@@ -151,12 +151,12 @@ int output_alias_op(const T& x, const std::vector<shape>& shapes)
returns
=
'
std
::
ostream
&
'
,
os
=
'
std
::
ostream
&
'
,
op
=
'
const
operation
&
'
,
using
=
'
migraph
::
operation_stream
::
operator
<<
'
),
using
=
'
migraph
x
::
operation_stream
::
operator
<<
'
),
friend
(
'
operator
==
'
,
returns
=
'
bool
'
,
x
=
'
const
operation
&
'
,
y
=
'
const
operation
&
'
,
using
=
'
migraph
::
operation_equal
::
operator
==
'
))
%>
using
=
'
migraph
x
::
operation_equal
::
operator
==
'
))
%>
inline
bool
operator
!=
(
const
operation
&
x
,
const
operation
&
y
)
{
...
...
@@ -165,6 +165,6 @@ int output_alias_op(const T& x, const std::vector<shape>& shapes)
#endif
}
// namespace migraph
}
// namespace migraph
x
#endif
tools/include/pass.hpp
View file @
65c5581f
...
...
@@ -8,7 +8,7 @@
#include <type_traits>
#include <utility>
namespace
migraph
{
namespace
migraph
x
{
struct
program
;
...
...
@@ -35,6 +35,6 @@ interface('pass',
#endif
}
// namespace migraph
}
// namespace migraph
x
#endif
tools/include/target.hpp
View file @
65c5581f
...
...
@@ -8,10 +8,10 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <migraph/context.hpp>
#include <migraph/pass.hpp>
#include <migraph
x
/context.hpp>
#include <migraph
x
/pass.hpp>
namespace
migraph
{
namespace
migraph
x
{
#ifdef DOXYGEN
...
...
@@ -48,6 +48,6 @@ interface('target',
#endif
}
// namespace migraph
}
// namespace migraph
x
#endif
Prev
1
…
6
7
8
9
10
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