Compute Library
 20.08
NEGEMM.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
27 #include "arm_compute/core/Error.h"
31 #include "arm_compute/core/Types.h"
37 
38 #include <cmath>
39 
41 
42 namespace arm_compute
43 {
44 NEGEMM::NEGEMM(std::shared_ptr<IMemoryManager> memory_manager, IWeightsManager *weights_manager)
45  : _memory_group(memory_manager), _weights_manager(weights_manager), _interleave_kernel(), _transpose_kernel(), _mm_kernel(), _asm_glue(memory_manager, weights_manager), _ma_kernel(),
46  _alpha_scale_func(nullptr), _add_bias(), _activation_func(), _tmp_a(), _tmp_b(), _tmp_d(), _original_b(nullptr), _run_vector_matrix_multiplication(false), _run_alpha_scale(false),
47  _run_addition(false), _run_bias_addition(false), _run_activation(false), _reshape_b_only_on_first_run(false), _is_prepared(false)
48 {
49 }
50 
51 void NEGEMM::configure(const ITensor *a, const ITensor *b, const ITensor *c, ITensor *d, float alpha, float beta, const GEMMInfo &gemm_info)
52 {
53  ARM_COMPUTE_ERROR_THROW_ON(NEGEMM::validate(a->info(), b->info(), (c != nullptr) ? c->info() : nullptr, d->info(), alpha, beta, gemm_info));
54 
55  const bool is_c_bias = gemm_info.reshape_b_only_on_first_run();
56  bool run_optimised = bool(NEGEMMAssemblyDispatch::validate(a->info(), b->info(), (is_c_bias && c != nullptr) ? c->info() : nullptr, d->info(), gemm_info));
57 
58  // Check if we need to reshape the matrix B only on the first run
59  _is_prepared = false;
60  _reshape_b_only_on_first_run = gemm_info.reshape_b_only_on_first_run();
61  _run_vector_matrix_multiplication = a->info()->dimension(1) < 2;
62  _original_b = b;
63  _run_alpha_scale = alpha != 1.f;
64  _run_bias_addition = c != nullptr && gemm_info.reshape_b_only_on_first_run();
65  _run_addition = beta != 0 && c != nullptr && !gemm_info.reshape_b_only_on_first_run();
66  _run_activation = gemm_info.activation_info().enabled() && (!run_optimised || (run_optimised && !NEGEMMAssemblyDispatch::is_activation_supported(gemm_info.activation_info())));
67 
68  if(run_optimised)
69  {
70  const ITensor *c_to_use = is_c_bias ? c : nullptr;
71  _asm_glue.configure(a, b, c_to_use, d, gemm_info);
72  ARM_COMPUTE_ERROR_ON(!_asm_glue.is_configured());
73 
74  // Scale product by alpha
75  if(_run_alpha_scale)
76  {
78  }
79  }
80  else
81  {
82  // Pick output tensor in case bias addition should be performed
83  ITensor *gemm_output_to_use = d;
84  if(_run_bias_addition)
85  {
86  gemm_output_to_use = &_tmp_d;
87  _memory_group.manage(&_tmp_d);
88  }
89 
90  // Select between GEMV and GEMM
91  if(_run_vector_matrix_multiplication)
92  {
93  // Configure the matrix multiply kernel
94  _mm_kernel.configure(a, b, gemm_output_to_use, alpha, false);
95  }
96  else
97  {
98  TensorShape shape_tmp_a = a->info()->tensor_shape();
99  TensorShape shape_tmp_b = b->info()->tensor_shape();
100 
101  shape_tmp_a.set(0, a->info()->dimension(0) * 4);
102  shape_tmp_a.set(1, std::ceil(a->info()->dimension(1) / 4.0f));
103 
104  const unsigned int transpose_w = 16 / data_size_from_type(b->info()->data_type());
105  shape_tmp_b.set(0, b->info()->dimension(1) * transpose_w);
106  shape_tmp_b.set(1, std::ceil(b->info()->dimension(0) / static_cast<float>(transpose_w)));
107 
108  TensorInfo info_a = a->info()->clone()->set_tensor_shape(shape_tmp_a).set_is_resizable(true);
109  TensorInfo info_b = b->info()->clone()->set_tensor_shape(shape_tmp_b).set_is_resizable(true);
110 
111  _tmp_a.allocator()->init(info_a);
112  _tmp_b.allocator()->init(info_b);
113 
114  // Manage intermediate buffers
115  _memory_group.manage(&_tmp_a);
116  if(!_reshape_b_only_on_first_run)
117  {
118  _memory_group.manage(&_tmp_b);
119  }
120 
121  int m = a->info()->dimension(1);
122  int n = b->info()->dimension(0);
123  int k = a->info()->dimension(0);
124 
125  // Configure interleave kernel
126  _interleave_kernel.configure(a, &_tmp_a);
127 
128  // Configure transpose kernel
129  _transpose_kernel.configure(b, &_tmp_b);
130 
131  // Configure matrix multiplication kernel
132  _mm_kernel.configure(&_tmp_a, &_tmp_b, gemm_output_to_use, alpha, true, GEMMReshapeInfo(m, n, k));
133 
134  // Allocate once the all configure methods have been called
135  _tmp_a.allocator()->allocate();
136  if(!_reshape_b_only_on_first_run)
137  {
138  _tmp_b.allocator()->allocate();
139  }
140  }
141 
142  if(_run_bias_addition)
143  {
144  _add_bias.configure(gemm_output_to_use, c, d, ConvertPolicy::SATURATE);
145  _tmp_d.allocator()->allocate();
146  }
147  }
148 
149  // Configure matrix addition kernel
150  if(_run_addition)
151  {
152  _ma_kernel.configure(c, d, beta);
153  }
154 
155  // Configure activation
156  const ActivationLayerInfo &activation = gemm_info.activation_info();
157  if(_run_activation)
158  {
159  _activation_func.configure(d, nullptr, activation);
160  }
161 }
162 
163 Status NEGEMM::validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, float alpha, float beta, const GEMMInfo &gemm_info)
164 {
166  const bool is_c_bias = gemm_info.reshape_b_only_on_first_run();
167 
172  ARM_COMPUTE_RETURN_ERROR_ON_MSG(a->dimension(0) != b->dimension(1), "The product AB is defined only if the number of columns in A is equal to the number of rows in B");
173  ARM_COMPUTE_RETURN_ERROR_ON_MSG(gemm_info.is_a_reshaped(), "Matrix A already reshaped is not supported");
174  ARM_COMPUTE_RETURN_ERROR_ON_MSG(gemm_info.is_b_reshaped(), "Matrix B already reshaped is not supported");
175  if(a->data_type() != DataType::BFLOAT16)
176  {
178  }
179 
180  if(c != nullptr && !is_c_bias)
181  {
185  ARM_COMPUTE_RETURN_ERROR_ON_MSG(a->dimension(1) != c->dimension(1), "The C matrix must have the same number of rows as the matrix A");
186  ARM_COMPUTE_RETURN_ERROR_ON_MSG(b->dimension(0) != c->dimension(0), "The C matrix must have the same number of columns as the matrix B");
187  }
188 
189  if(output->total_size() != 0)
190  {
191  ARM_COMPUTE_RETURN_ERROR_ON(b->dimension(0) != output->dimension(0));
192  if(gemm_info.depth_output_gemm3d() != 0)
193  {
194  if(gemm_info.reinterpret_input_as_3d())
195  {
196  ARM_COMPUTE_RETURN_ERROR_ON(a->dimension(1) != output->dimension(1));
197  ARM_COMPUTE_RETURN_ERROR_ON(a->dimension(2) != output->dimension(2));
198  }
199  else
200  {
201  ARM_COMPUTE_RETURN_ERROR_ON(a->dimension(1) != output->dimension(1) * output->dimension(2));
202  }
203  }
204  else
205  {
206  ARM_COMPUTE_RETURN_ERROR_ON(a->dimension(1) != output->dimension(1));
207  }
208  }
209 
210  // Check if we need to run the optimized assembly kernel
211  const bool run_optimised = bool(NEGEMMAssemblyDispatch::validate(a, b, is_c_bias ? c : nullptr, output, gemm_info));
212 
213  if(!run_optimised)
214  {
215  ARM_COMPUTE_RETURN_ERROR_ON_MSG(gemm_info.reinterpret_input_as_3d(), "NEGEMM cannot reinterpret the input tensor as 3D");
216  ARM_COMPUTE_RETURN_ERROR_ON_MSG(gemm_info.depth_output_gemm3d() != 0, "NEGEMM cannot reinterpret the output tensor as 3D");
217 
218  // Check if the first input tensor is a vector.
219  const bool run_vector_matrix_multiplication = a->dimension(1) < 2;
220  // Check if we need to reshape the matrix A and matrix B
221  const bool run_interleave_transpose = !run_vector_matrix_multiplication && !(gemm_info.reshape_b_only_on_first_run());
222 
223  // Arguments used by GEMMReshapeInfo
224  // If we pass the matrix A and matrix B reshaped to NEGEMMMatrixMultiplyKernel, we need to pass m, n, k, mult_transpose1xW_width and mult_interleave4x4_height to NEGEMMReshapeInfo
225  // in order to know how the matrices have been reshaped
226  const int m = a->dimension(1);
227  const int n = b->dimension(0);
228  const int k = a->dimension(0);
229  int mult_transpose1xW_width = 1;
230  int mult_interleave4x4_height = 1;
231 
232  const GEMMReshapeInfo reshape_info = GEMMReshapeInfo(m, n, k, mult_transpose1xW_width, mult_interleave4x4_height, gemm_info.depth_output_gemm3d());
233 
234  const ITensorInfo *matrix_a_info = a;
235  const ITensorInfo *matrix_b_info = b;
236 
237  TensorInfo tmp_a_info{};
238  TensorInfo tmp_b_info{};
239  TensorInfo tmp_output_info = *output->clone();
240 
241  if(run_interleave_transpose)
242  {
243  matrix_a_info = &tmp_a_info;
244  matrix_b_info = &tmp_b_info;
245 
246  // Validate interleave kernel
247  auto_init_if_empty(tmp_a_info, a->clone()->set_tensor_shape(compute_interleaved_shape(*a, mult_interleave4x4_height, gemm_info.reinterpret_input_as_3d())));
249 
250  // Validate transpose kernel
251  auto_init_if_empty(tmp_b_info, b->clone()->set_tensor_shape(compute_transpose1xW_with_element_size_shape(*b, mult_transpose1xW_width)));
253  }
254 
255  // Validate matrix multiply
256  auto_init_if_empty(tmp_output_info, matrix_a_info->clone()->set_tensor_shape(compute_mm_shape(*matrix_a_info, *matrix_b_info, run_interleave_transpose, reshape_info)));
257  ARM_COMPUTE_RETURN_ON_ERROR(NEGEMMMatrixMultiplyKernel::validate(matrix_a_info, matrix_b_info, &tmp_output_info, alpha, run_interleave_transpose, reshape_info));
258 
259  if(c != nullptr && gemm_info.reshape_b_only_on_first_run())
260  {
262  }
263  }
264 
265  // Validate matrix addition kernel
266  if(beta != 0 && c != nullptr && !is_c_bias)
267  {
269  }
270 
271  // Validate activation
272  const ActivationLayerInfo &activation = gemm_info.activation_info();
273  if(activation.enabled())
274  {
275  ARM_COMPUTE_RETURN_ON_ERROR(NEActivationLayer::validate(output, nullptr, activation));
276  }
277 
278  return Status{};
279 }
280 
282 {
283  prepare();
284 
285  MemoryGroupResourceScope scope_mg(_memory_group);
286 
287  if(_asm_glue.is_configured())
288  {
289  _asm_glue.run();
290  if(_run_alpha_scale)
291  {
292  _alpha_scale_func.run();
293  }
294  }
295  else
296  {
297  if(!_run_vector_matrix_multiplication)
298  {
299  // Run interleave kernel
300  NEScheduler::get().schedule(&_interleave_kernel, Window::DimY);
301 
302  if(!_reshape_b_only_on_first_run)
303  {
304  // Run transpose kernel
305  NEScheduler::get().schedule(&_transpose_kernel, Window::DimY);
306  }
307  }
308 
309  NEScheduler::get().schedule(&_mm_kernel, _run_vector_matrix_multiplication ? Window::DimX : Window::DimY);
310 
311  // Run bias addition kernel
312  if(_run_bias_addition)
313  {
314  _add_bias.run();
315  }
316  }
317 
318  // Run matrix addition kernel
319  if(_run_addition)
320  {
321  NEScheduler::get().schedule(&_ma_kernel, Window::DimY);
322  }
323 
324  // Run activation function
325  if(_run_activation)
326  {
327  _activation_func.run();
328  }
329 }
330 
332 {
333  if(!_is_prepared)
334  {
335  const bool original_b_managed_by_weights_manager = _weights_manager && _weights_manager->are_weights_managed(_original_b);
336  if(_asm_glue.is_configured())
337  {
338  if(!original_b_managed_by_weights_manager)
339  {
340  ARM_COMPUTE_ERROR_ON(!_original_b->is_used());
341  }
342 
343  _asm_glue.prepare();
344  if(!original_b_managed_by_weights_manager)
345  {
346  _original_b->mark_as_unused();
347  }
348  }
349  else if(_reshape_b_only_on_first_run && !_run_vector_matrix_multiplication && !_asm_glue.is_configured())
350  {
351  if(!original_b_managed_by_weights_manager)
352  {
353  ARM_COMPUTE_ERROR_ON(!_original_b->is_used());
354  }
355 
356  _tmp_b.allocator()->allocate();
357  NEScheduler::get().schedule(&_transpose_kernel, Window::DimY);
358  if(!original_b_managed_by_weights_manager)
359  {
360  _original_b->mark_as_unused();
361  }
362  }
363 
364  _is_prepared = true;
365  }
366 }
367 } // namespace arm_compute
Shape of a tensor.
Definition: TensorShape.h:39
TensorShape compute_transpose1xW_with_element_size_shape(const ITensorInfo &b, int mult_transpose1xW_width=1)
Calculate the transposed 1xW width element shape.
std::unique_ptr< ITensorInfo > clone() const override
Provide a clone of the current object of class T.
Definition: TensorInfo.cpp:314
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of NEArithmeticAddition.
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
bool enabled() const
Check if initialised.
Definition: Types.h:1567
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
SimpleTensor< float > b
Definition: DFT.cpp:157
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
GEMM reshape information class.
Definition: Types.h:1760
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
virtual DataType data_type() const =0
Data type used for each element of the tensor.
TensorShape compute_mm_shape(const ITensorInfo &input0, const ITensorInfo &input1, bool is_interleaved_transposed, const GEMMReshapeInfo &reshape_info)
Calculate the matrix multiplication output shape of two tensors.
bool is_used() const
Flags if the tensor is used or not.
Definition: ITensor.cpp:163
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ActivationLayerInfo &act_info)
[NEActivationLayer snippet]
void run() override
Run the kernels contained in the function.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:792
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Store the tensor's metadata.
Definition: ITensorInfo.h:40
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
int depth_output_gemm3d() const
Depth of the output when GEMM output is reinterpreted as 3D tensor.
Definition: Types.h:2011
Status class.
Definition: Error.h:52
void run() override
Run the kernels contained in the function.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
Activation Layer Information class.
Definition: Types.h:1517
Interface for NEON tensor.
Definition: ITensor.h:36
static Status validate(const ITensorInfo *input, const ITensorInfo *output, float beta)
Static function to check if given info will lead to a valid configuration of NEGEMMMatrixAdditionKern...
void configure(const ITensor *input1, const ITensor *input2, ITensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel's inputs, output and conversion policy.
TensorShape compute_interleaved_shape(const ITensorInfo &a, int mult_interleave4x4_height=1, bool reinterpret_input_as_3d=false)
Calculate the interleaved shape of an input tensor.
NEGEMM(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Constructor.
Definition: NEGEMM.cpp:44
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEGEMMTranspose1xWKernel...
Copyright (c) 2017-2020 Arm Limited.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Definition: Helpers.inl:207
bool is_b_reshaped() const
Flag which specifies if the matrix B has been reshaped.
Definition: Types.h:1993
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
Definition: Validate.h:108
1 channel, 1 F16 per channel
TensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Definition: Tensor.cpp:48
void mark_as_unused() const
Marks a tensor as unused.
Definition: ITensor.cpp:168
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
16-bit brain floating-point number
bool are_weights_managed(const ITensor *weights)
Check if the weights are managed.
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, float alpha, float beta, const GEMMInfo &gemm_info=GEMMInfo())
Static function to check if given info will lead to a valid configuration of NEGEMM.
Definition: NEGEMM.cpp:163
void run() override
Run the kernels contained in the function.
Definition: NEGEMM.cpp:281
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
static bool is_activation_supported(const ActivationLayerInfo &activation)
Checks if activation is supported by the gemm assembly dispatcher.
void prepare() override
Runs a preparation step, usually for pre-transposing matrix b.
void run() override
Run the kernels contained in the function.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
bool is_configured() const
Was the function successfully configured ?
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEGEMMInterleave4x4Kerne...
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
void configure(const ITensor *input, ITensor *output)
Initialise the kernel's input and output.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
size_t data_size_from_type(DataType data_type)
The size in bytes of the data type.
Definition: Utils.h:102
bool reinterpret_input_as_3d() const
Flag which specifies if the input tensor has to be reinterpreted as 3D.
Definition: Types.h:2019
Weights manager interface to handle weights transformations.
void configure(const ITensor *input, ITensor *output)
Initialise the kernel's input and output.
bool is_a_reshaped() const
Flag which specifies if the matrix A has been reshaped.
Definition: Types.h:1985
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *d, const GEMMInfo &gemm_info)
Indicates whether or not this function can be used to process the given parameters.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
Memory group resources scope handling class.
Definition: IMemoryGroup.h:82
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
void configure(const ITensor *input0, const ITensor *input1, ITensor *output, float alpha, bool is_interleaved, const GEMMReshapeInfo &reshape_info=GEMMReshapeInfo())
Initialise the kernel's input and output.
void configure(const ITensor *a, const ITensor *b, const ITensor *c, ITensor *d, float alpha, float beta, const GEMMInfo &gemm_info=GEMMInfo())
Initialise the kernel's inputs, output.
Definition: NEGEMM.cpp:51
void configure(ITensor *input, ITensor *output, ActivationLayerInfo activation_info)
[NEActivationLayer snippet]
void configure(const ITensor *input, ITensor *output, float beta)
Initialise the kernel's input and output.
void prepare() override
Prepare the function for executing.
Definition: NEGEMM.cpp:331
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Definition: Error.h:244
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true)
Accessor to set the value of one of the dimensions.
Definition: TensorShape.h:78
Store the tensor's metadata.
Definition: TensorInfo.h:45
bool reshape_b_only_on_first_run() const
Flag which specifies if the reshape of matrix B should executed only for the first.
Definition: Types.h:2003
void configure(const ITensor *a, const ITensor *b, const ITensor *c, ITensor *d, const GEMMInfo &gemm_info)
If supported create an ACL function else fallback to the arm_gemm function.
static Status validate(const ITensorInfo *input0, const ITensorInfo *input1, const ITensorInfo *output, float alpha, bool is_interleaved, const GEMMReshapeInfo &reshape_info)
Static function to check if given info will lead to a valid configuration of NEGEMMMatrixMultiplyKern...
GEMM information class.
Definition: Types.h:1932
ActivationLayerInfo activation_info() const
Activation layer to apply after the matrix multiplication.
Definition: Types.h:2083
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_BF16_UNSUPPORTED(tensor)
Definition: Validate.h:114
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:95