MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / TEST

Function TEST

oneflow/api/cpp/tests/ivalue_test.cpp:31–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31TEST(Api, ivalue) {
32 std::uniform_real_distribution<> dist(-100, 100);
33 std::uniform_int_distribution<> dist_bool(0, 1);
34
35 const auto v_int = static_cast<int>(dist(rng));
36 ASSERT_EQ(IValue(v_int).ToInt(), v_int);
37
38 const auto v_int64 = static_cast<int64_t>(dist(rng));
39 ASSERT_EQ(IValue(v_int64).ToInt(), v_int64);
40
41 const auto v_float = static_cast<float>(dist(rng));
42 ASSERT_EQ(IValue(v_float).ToDouble(), v_float);
43
44 const auto v_double = static_cast<double>(dist(rng));
45 ASSERT_EQ(IValue(v_double).ToDouble(), v_double);
46
47 const auto v_bool = static_cast<bool>(dist_bool(rng));
48 ASSERT_EQ(IValue(v_bool).ToBool(), v_bool);
49}
50
51TEST(Api, ivalue_tensor) {
52 EnvScope scope;

Callers

nothing calls this directly

Calls 12

IValueClass · 0.85
RandomShapeFunction · 0.85
ToIntMethod · 0.80
ToDoubleMethod · 0.80
ToBoolMethod · 0.80
DeviceClass · 0.50
TensorClass · 0.50
shapeMethod · 0.45
deviceMethod · 0.45
dtypeMethod · 0.45
sizeMethod · 0.45
IsNoneMethod · 0.45

Tested by

no test coverage detected