MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / TEST_CASE

Function TEST_CASE

tests/validation/NEON/GEMM.cpp:125–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123 * - Both runs compute the same output
124 */
125TEST_CASE(MemoryInjection, framework::DatasetMode::ALL)
126{
127 auto gemm = std::make_unique<cpu::CpuGemm>();
128 const auto lhs_info = TensorInfo(TensorShape(3U, 3U), 1, DataType::F32);
129 const auto rhs_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
130 const auto c_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
131 auto dst_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
132 const auto gemm_info = GEMMInfo{};
133 gemm->configure(&lhs_info, &rhs_info, &c_info, &dst_info, 1.f, 1.f, gemm_info);
134
135 // telhs are newly created every call of this lambda function
136 auto lhs = create_tensor<Tensor>(lhs_info);
137 auto rhs = create_tensor<Tensor>(rhs_info);
138 auto c = create_tensor<Tensor>(c_info);
139 lhs.allocator()->allocate();
140 rhs.allocator()->allocate();
141 c.allocator()->allocate();
142
143 ITensorPack run_pack{{TensorType::ACL_SRC_0, &lhs}, {TensorType::ACL_SRC_1, &rhs}, {TensorType::ACL_SRC_2, &c}};
144 ITensorPack prep_pack{{TensorType::ACL_SRC_1, &rhs}, {TensorType::ACL_SRC_2, &c}};
145
146 auto mg = MemoryGroup{};
147 auto ws = manage_workspace<Tensor>(gemm->workspace(), mg, run_pack, prep_pack);
148
149 auto run_conv = [&]() -> Tensor
150 {
151 auto dst = create_tensor<Tensor>(dst_info);
152 dst.allocator()->allocate();
153 run_pack.add_tensor(TensorType::ACL_DST, &dst);
154
155 library->fill_tensor_value(Accessor(lhs), 1.f);
156 library->fill_tensor_value(Accessor(rhs), 2.f);
157 library->fill_tensor_value(Accessor(c), 3.f);
158 // This operator is configured once and captured by this lambda.
159 gemm->prepare(prep_pack);
160 gemm->run(run_pack);
161 return dst;
162 };
163 auto result_0 = run_conv();
164 auto result_1 = run_conv();
165 for (size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
166 {
167 ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i],
168 framework::LogLevel::ERRORS);
169 }
170}
171
172/** Test case for memory injection in @ref NEGEMM.
173 *

Callers

nothing calls this directly

Calls 14

AccessorClass · 0.85
fill_tensor_valueMethod · 0.80
TensorInfoClass · 0.50
TensorShapeClass · 0.50
configureMethod · 0.45
allocateMethod · 0.45
allocatorMethod · 0.45
workspaceMethod · 0.45
add_tensorMethod · 0.45
prepareMethod · 0.45
runMethod · 0.45
total_sizeMethod · 0.45

Tested by

no test coverage detected