forked from clab/dynet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add doc and reimplement Dim::truncate (clab#970)
* remote use GPU:0 by default when use --dynet-gpu * fix error * Comment DeviceMempool enum * clab#945 1. add doc for Dim::truncate 2. reimplement Dim::truncate 3. add tests for dim
- Loading branch information
1 parent
29536c4
commit 0c6c6de
Showing
3 changed files
with
46 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#define BOOST_TEST_MODULE TEST_DIM | ||
|
||
#include <dynet/dim.h> | ||
|
||
#include "test.h" | ||
|
||
using namespace dynet; | ||
|
||
struct DimTest { | ||
|
||
}; | ||
|
||
BOOST_FIXTURE_TEST_SUITE(dim_test, DimTest); | ||
|
||
BOOST_AUTO_TEST_CASE( test_dim_truncate_no_trailing_one ) { | ||
Dim d1({1,3,4}); | ||
Dim t1 = d1.truncate(); | ||
BOOST_CHECK_EQUAL(t1.nd, 3); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( test_dim_truncate_all_one ) { | ||
Dim d1({1,1,1}); | ||
Dim t1 = d1.truncate(); | ||
BOOST_CHECK_EQUAL(t1.nd, 1); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( test_dim_truncate_trailing_one ) { | ||
Dim d1({4,3,1}); | ||
Dim t1 = d1.truncate(); | ||
BOOST_CHECK_EQUAL(t1.nd, 2); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( test_dim_truncate_multiple_one ) { | ||
Dim d1({4,1,1}); | ||
Dim t1 = d1.truncate(); | ||
BOOST_CHECK_EQUAL(t1.nd, 1); | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() | ||
|