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

Function TestRelu

oneflow/api/cpp/tests/nn_test.cpp:40–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38} // namespace
39
40void TestRelu() {
41 const auto shape = RandomShape();
42 const auto data = RandomData<float>(shape.Count(0));
43 const auto target_data = Relu(data);
44 std::vector<float> result(shape.Count(0));
45
46 auto tensor = Tensor::from_buffer(data.data(), shape, Device("cpu"), DType::kFloat);
47 auto result_tensor = nn::relu(tensor);
48
49 result_tensor.copy_to(result.data());
50
51 ASSERT_EQ(result, target_data);
52}
53
54TEST(Api, nn_relu) {
55 EnvScope scope;

Callers 1

TESTFunction · 0.85

Calls 7

RandomShapeFunction · 0.85
reluFunction · 0.85
copy_toMethod · 0.80
ReluFunction · 0.70
DeviceClass · 0.50
CountMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected