| 16 | namespace custom { |
| 17 | |
| 18 | TEST(TestDevice, TestDevice) { |
| 19 | #if MGB_CUDA |
| 20 | ASSERT_TRUE(Device::is_legal("x86")); |
| 21 | ASSERT_TRUE(Device::is_legal(DeviceEnum::cuda)); |
| 22 | ASSERT_FALSE(Device::is_legal("cpu")); |
| 23 | |
| 24 | Device dev1; |
| 25 | ASSERT_TRUE(dev1.str() == "invalid"); |
| 26 | |
| 27 | dev1 = "x86"; |
| 28 | ASSERT_TRUE("x86" == dev1); |
| 29 | |
| 30 | Device dev2 = "cuda"; |
| 31 | ASSERT_TRUE(dev2 == "cuda"); |
| 32 | ASSERT_FALSE(dev2 == dev1); |
| 33 | |
| 34 | Device dev3 = dev2; |
| 35 | ASSERT_TRUE(dev3 == dev2); |
| 36 | ASSERT_FALSE(dev3 == dev1); |
| 37 | |
| 38 | Device dev4 = DeviceEnum::cuda; |
| 39 | ASSERT_TRUE(dev4.enumv() == DeviceEnum::cuda); |
| 40 | |
| 41 | #if TENSOR_TEST_LOG |
| 42 | std::cout << dev1.str() << "\n" |
| 43 | << dev2.str() << "\n" |
| 44 | << dev3.str() << "\n" |
| 45 | << dev4.str() << std::endl; |
| 46 | #endif |
| 47 | |
| 48 | CompNode compnode = to_builtin<CompNode, Device>(dev3); |
| 49 | ASSERT_TRUE(compnode.to_string_logical() == "gpux:0"); |
| 50 | compnode = CompNode::load("cpu0:0"); |
| 51 | Device dev5 = to_custom<CompNode, Device>(compnode); |
| 52 | ASSERT_TRUE(dev5.str() == "x86"); |
| 53 | |
| 54 | std::vector<Device> devs1 = {"x86", "cuda", "x86"}; |
| 55 | megdnn::SmallVector<CompNode> compnodes = to_builtin<CompNode, Device>(devs1); |
| 56 | ASSERT_TRUE(compnodes[0].to_string_logical() == "cpux:0"); |
| 57 | ASSERT_TRUE(compnodes[1].to_string_logical() == "gpux:0"); |
| 58 | ASSERT_TRUE(compnodes[2].to_string_logical() == "cpux:0"); |
| 59 | |
| 60 | std::vector<Device> devs2 = to_custom<CompNode, Device>(compnodes); |
| 61 | ASSERT_TRUE(devs2[0] == "x86"); |
| 62 | ASSERT_TRUE(devs2[1].str() == "cuda"); |
| 63 | ASSERT_TRUE(devs2[2] == "x86"); |
| 64 | #endif |
| 65 | } |
| 66 | |
| 67 | TEST(TestShape, TestShape) { |
| 68 | Shape shape1, shape2; |
nothing calls this directly
no test coverage detected