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

Function Forward

oneflow/api/cpp/tests/graph_test.cpp:41–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41inline void Forward(Graph& graph, const Device& device, int expected_batch_dim = 1) {
42 std::vector<float> data(expected_batch_dim * 3);
43 std::fill(data.begin(), data.end(), 1);
44 std::vector<Tensor> inputs;
45 inputs.emplace_back(
46 Tensor::from_buffer(data.data(), Shape({expected_batch_dim, 3}), device, DType::kFloat));
47 const auto& value = graph.Forward(inputs);
48 ASSERT_TRUE(value.IsTensor());
49 Tensor output = value.ToTensor();
50 Shape shape = output.shape();
51 ASSERT_EQ(shape.At(0), expected_batch_dim);
52 ASSERT_EQ(shape.At(1), 4);
53 std::vector<float> buf(expected_batch_dim * 4);
54 output.copy_to(buf.data());
55 for (const float& element : buf) { ASSERT_EQ(element, 4); }
56}
57
58} // namespace
59

Callers 15

ComputeMethod · 0.85
operator()Method · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
WriteSliceFunction · 0.85
operator()Method · 0.85
operator()Method · 0.85
GatherForwardFunction · 0.85
ForwardMethod · 0.85

Calls 10

copy_toMethod · 0.80
ShapeClass · 0.50
beginMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45
dataMethod · 0.45
ForwardMethod · 0.45
IsTensorMethod · 0.45
shapeMethod · 0.45
AtMethod · 0.45

Tested by

no test coverage detected