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
564d38e5
"test/vscode:/vscode.git/clone" did not exist on "7ce6c10eb6ecf1703a8b2bb480d275d5ee1bf42f"
Commit
564d38e5
authored
Nov 22, 2022
by
charlie
Browse files
Add dynamic_dimension == size_t compares
parent
3feedaee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
src/include/migraphx/shape.hpp
src/include/migraphx/shape.hpp
+6
-0
src/shape.cpp
src/shape.cpp
+8
-0
test/shape_test.cpp
test/shape_test.cpp
+14
-0
No files found.
src/include/migraphx/shape.hpp
View file @
564d38e5
...
@@ -101,6 +101,12 @@ struct shape
...
@@ -101,6 +101,12 @@ struct shape
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
dynamic_dimension
&
y
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
dynamic_dimension
&
x
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
dynamic_dimension
&
x
);
// compare to fixed std::size_t dimension
friend
bool
operator
==
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
friend
bool
operator
==
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
friend
bool
operator
!=
(
const
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
);
friend
bool
operator
!=
(
const
std
::
size_t
&
x
,
const
dynamic_dimension
&
y
);
};
};
static
const
std
::
vector
<
type_t
>&
types
();
static
const
std
::
vector
<
type_t
>&
types
();
...
...
src/shape.cpp
View file @
564d38e5
...
@@ -521,6 +521,14 @@ std::ostream& operator<<(std::ostream& os, const shape::dynamic_dimension& x)
...
@@ -521,6 +521,14 @@ std::ostream& operator<<(std::ostream& os, const shape::dynamic_dimension& x)
return
os
;
return
os
;
}
}
bool
operator
==
(
const
shape
::
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
)
{
return
x
.
min
==
y
and
x
.
max
==
y
;
}
bool
operator
==
(
const
std
::
size_t
&
x
,
const
shape
::
dynamic_dimension
&
y
)
{
return
y
==
x
;
}
bool
operator
!=
(
const
shape
::
dynamic_dimension
&
x
,
const
std
::
size_t
&
y
)
{
return
!
(
x
==
y
);
}
bool
operator
!=
(
const
std
::
size_t
&
x
,
const
shape
::
dynamic_dimension
&
y
)
{
return
!
(
x
==
y
);
}
bool
operator
==
(
const
shape
&
x
,
const
shape
&
y
)
bool
operator
==
(
const
shape
&
x
,
const
shape
&
y
)
{
{
if
(
x
.
dynamic
()
and
y
.
dynamic
())
if
(
x
.
dynamic
()
and
y
.
dynamic
())
...
...
test/shape_test.cpp
View file @
564d38e5
...
@@ -160,6 +160,20 @@ TEST_CASE(test_shape_dynamic_compares)
...
@@ -160,6 +160,20 @@ TEST_CASE(test_shape_dynamic_compares)
EXPECT
(
ss0
.
str
()
!=
ss3
.
str
());
EXPECT
(
ss0
.
str
()
!=
ss3
.
str
());
}
}
TEST_CASE
(
dynamic_dimension_size_t_compares
)
{
using
migraphx
::
shape
;
auto
a
=
shape
::
dynamic_dimension
{
2
,
2
,
2
};
EXPECT
(
a
==
2
);
EXPECT
(
a
!=
3
);
EXPECT
(
static_cast
<
std
::
size_t
>
(
2
)
==
a
);
EXPECT
(
static_cast
<
std
::
size_t
>
(
3
)
!=
a
);
auto
b
=
shape
::
dynamic_dimension
{
2
,
4
,
0
};
EXPECT
(
b
!=
2
);
EXPECT
(
static_cast
<
std
::
size_t
>
(
2
)
!=
b
);
}
TEST_CASE
(
test_shape_dynamic_errors
)
TEST_CASE
(
test_shape_dynamic_errors
)
{
{
using
migraphx
::
shape
;
using
migraphx
::
shape
;
...
...
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