Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
89e17047
Commit
89e17047
authored
May 15, 2019
by
Scott Cyphers
Committed by
Robert Kimball
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some assignment tests for [b]float16 (#2933)
parent
051595e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
bfloat16.cpp
test/bfloat16.cpp
+33
-0
float16.cpp
test/float16.cpp
+23
-0
No files found.
test/bfloat16.cpp
View file @
89e17047
...
...
@@ -225,3 +225,36 @@ TEST(benchmark, bfloat16)
<<
"ms"
;
}
}
TEST
(
bfloat16
,
assigns
)
{
bfloat16
bf16
;
bf16
=
2.0
;
EXPECT_EQ
(
bf16
,
float16
(
2.0
));
std
::
vector
<
float
>
f32vec
{
1.0
,
2.0
,
4.0
};
std
::
vector
<
bfloat16
>
bf16vec
;
std
::
copy
(
f32vec
.
begin
(),
f32vec
.
end
(),
std
::
back_inserter
(
bf16vec
));
for
(
int
i
=
0
;
i
<
f32vec
.
size
();
++
i
)
{
EXPECT_EQ
(
f32vec
.
at
(
i
),
bf16vec
.
at
(
i
));
}
f32vec
=
{
-
1.0
,
-
2.0
,
-
3.0
};
for
(
int
i
=
0
;
i
<
f32vec
.
size
();
++
i
)
{
bf16vec
[
i
]
=
f32vec
[
i
];
}
for
(
int
i
=
0
;
i
<
f32vec
.
size
();
++
i
)
{
EXPECT_EQ
(
f32vec
.
at
(
i
),
bf16vec
.
at
(
i
));
}
float
f32arr
[]
=
{
1.0
,
2.0
,
4.0
};
bfloat16
bf16arr
[
sizeof
(
f32arr
)];
for
(
int
i
=
0
;
i
<
sizeof
(
f32arr
)
/
sizeof
(
f32arr
[
0
]);
++
i
)
{
bf16arr
[
i
]
=
f32arr
[
i
];
EXPECT_EQ
(
f32arr
[
i
],
bf16arr
[
i
]);
}
}
test/float16.cpp
View file @
89e17047
...
...
@@ -64,3 +64,26 @@ TEST(float16, conversions)
EXPECT_STREQ
(
source_string
,
f16_string
.
c_str
());
EXPECT_EQ
(
static_cast
<
float
>
(
f16
),
1.5
);
}
TEST
(
float16
,
assigns
)
{
float16
f16
;
f16
=
2.0
;
EXPECT_EQ
(
f16
,
float16
(
2.0
));
std
::
vector
<
float
>
f32vec
{
1.0
,
2.0
,
4.0
};
std
::
vector
<
float16
>
f16vec
;
std
::
copy
(
f32vec
.
begin
(),
f32vec
.
end
(),
std
::
back_inserter
(
f16vec
));
for
(
int
i
=
0
;
i
<
f32vec
.
size
();
++
i
)
{
EXPECT_EQ
(
f32vec
.
at
(
i
),
f16vec
.
at
(
i
));
}
float
f32arr
[]
=
{
1.0
,
2.0
,
4.0
};
float16
f16arr
[
sizeof
(
f32arr
)];
for
(
int
i
=
0
;
i
<
sizeof
(
f32arr
)
/
sizeof
(
f32arr
[
0
]);
++
i
)
{
f16arr
[
i
]
=
f32arr
[
i
];
EXPECT_EQ
(
f32arr
[
i
],
f16arr
[
i
]);
}
}
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