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
104fd3ee
Commit
104fd3ee
authored
Aug 08, 2018
by
Robert Kimball
Committed by
Scott Cyphers
Aug 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing unit tests (#1373)
parent
0bddb26d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
1 deletion
+108
-1
backend_test.in.cpp
test/backend_test.in.cpp
+108
-1
No files found.
test/backend_test.in.cpp
View file @
104fd3ee
...
...
@@ -156,7 +156,29 @@ NGRAPH_TEST(${BACKEND_NAME}, parameter_as_output)
EXPECT_EQ
(
read_vector
<
float
>
(
result
),
expected
);
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
ab
)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
add
)
{
Shape
shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Add
>
(
A
,
B
),
op
::
ParameterVector
{
A
,
B
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
// Create some tensors for input/output
shared_ptr
<
runtime
::
TensorView
>
a
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
TensorView
>
b
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
TensorView
>
result
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
a
,
test
::
NDArray
<
float
,
2
>
({{
1
,
2
},
{
3
,
4
}}).
get_vector
());
copy_data
(
b
,
test
::
NDArray
<
float
,
2
>
({{
5
,
6
},
{
7
,
8
}}).
get_vector
());
backend
->
call
(
f
,
{
result
},
{
a
,
b
});
EXPECT_EQ
(
read_vector
<
float
>
(
result
),
(
test
::
NDArray
<
float
,
2
>
({{
6
,
8
},
{
10
,
12
}})).
get_vector
());
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
add_overload
)
{
Shape
shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
...
...
@@ -178,6 +200,50 @@ NGRAPH_TEST(${BACKEND_NAME}, ab)
(
test
::
NDArray
<
float
,
2
>
({{
6
,
8
},
{
10
,
12
}})).
get_vector
());
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
multiply
)
{
Shape
shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Multiply
>
(
A
,
B
),
op
::
ParameterVector
{
A
,
B
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
// Create some tensors for input/output
shared_ptr
<
runtime
::
TensorView
>
a
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
TensorView
>
b
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
TensorView
>
result
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
a
,
test
::
NDArray
<
float
,
2
>
({{
1
,
2
},
{
3
,
4
}}).
get_vector
());
copy_data
(
b
,
test
::
NDArray
<
float
,
2
>
({{
5
,
6
},
{
7
,
8
}}).
get_vector
());
backend
->
call
(
f
,
{
result
},
{
a
,
b
});
EXPECT_EQ
(
read_vector
<
float
>
(
result
),
(
test
::
NDArray
<
float
,
2
>
({{
5
,
12
},
{
21
,
32
}})).
get_vector
());
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
multiply_overload
)
{
Shape
shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
f
=
make_shared
<
Function
>
(
A
*
B
,
op
::
ParameterVector
{
A
,
B
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
// Create some tensors for input/output
shared_ptr
<
runtime
::
TensorView
>
a
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
TensorView
>
b
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
shared_ptr
<
runtime
::
TensorView
>
result
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
a
,
test
::
NDArray
<
float
,
2
>
({{
1
,
2
},
{
3
,
4
}}).
get_vector
());
copy_data
(
b
,
test
::
NDArray
<
float
,
2
>
({{
5
,
6
},
{
7
,
8
}}).
get_vector
());
backend
->
call
(
f
,
{
result
},
{
a
,
b
});
EXPECT_EQ
(
read_vector
<
float
>
(
result
),
(
test
::
NDArray
<
float
,
2
>
({{
5
,
12
},
{
21
,
32
}})).
get_vector
());
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
abc
)
{
Shape
shape
{
2
,
2
};
...
...
@@ -784,6 +850,27 @@ NGRAPH_TEST(${BACKEND_NAME}, divide)
EXPECT_EQ
((
vector
<
float
>
{
2
,
2
,
2
,
2
}),
read_vector
<
float
>
(
result
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
divide_overload
)
{
Shape
shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
f
=
make_shared
<
Function
>
(
A
/
B
,
op
::
ParameterVector
{
A
,
B
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
// Create some tensors for input/output
auto
a
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
a
,
vector
<
float
>
{
2
,
4
,
8
,
16
});
auto
b
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
b
,
vector
<
float
>
{
1
,
2
,
4
,
8
});
auto
result
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
backend
->
call
(
f
,
{
result
},
{
a
,
b
});
EXPECT_EQ
((
vector
<
float
>
{
2
,
2
,
2
,
2
}),
read_vector
<
float
>
(
result
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
divide_adjoint_stability
)
{
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
...
...
@@ -1616,6 +1703,26 @@ NGRAPH_TEST(${BACKEND_NAME}, subtract)
EXPECT_EQ
((
vector
<
float
>
{
1
,
2
,
4
,
8
}),
read_vector
<
float
>
(
result
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
subtract_overload
)
{
Shape
shape
{
2
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape
);
auto
f
=
make_shared
<
Function
>
(
A
-
B
,
op
::
ParameterVector
{
A
,
B
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
// Create some tensors for input/output
auto
a
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
a
,
vector
<
float
>
{
2
,
4
,
8
,
16
});
auto
b
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
copy_data
(
b
,
vector
<
float
>
{
1
,
2
,
4
,
8
});
auto
result
=
backend
->
create_tensor
(
element
::
f32
,
shape
);
backend
->
call
(
f
,
{
result
},
{
a
,
b
});
EXPECT_EQ
((
vector
<
float
>
{
1
,
2
,
4
,
8
}),
read_vector
<
float
>
(
result
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
tensor_constant
)
{
Shape
shape
{
2
,
2
,
2
};
...
...
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