MCPcopy Create free account
hub / github.com/LBANN/lbann / make_reference

Method make_reference

ci_test/common_python/test_util.py:209–238  ·  view source on GitHub ↗

Marks the given tensor as a reference output of the tested LBANN model, and returns a matching LBANN node. :param ref: The reference NumPy array to use. :return: An LBANN layer object that will serve as the reference.

(self, ref: Any)

Source from the content-addressed store, hash-verified

207 return slice_to_tensors(x, *tensors)
208
209 def make_reference(self, ref: Any) -> lbann.Input:
210 """
211 Marks the given tensor as a reference output of the tested LBANN model,
212 and returns a matching LBANN node.
213
214 :param ref: The reference NumPy array to use.
215 :return: An LBANN layer object that will serve as the reference.
216 """
217 # The reference is the second part of the input "samples"
218 refnode = lbann.Input(data_field='samples')
219 if self.input_tensor is None:
220 raise ValueError('Please call ``inputs`` or ``inputs_like`` prior '
221 'to calling ``make_reference`` for correctness.')
222 mbsize = self.input_tensor.shape[0]
223
224 # Obtain reference
225 refnode = lbann.Reshape(lbann.Identity(
226 lbann.Slice(
227 refnode,
228 slice_points=[
229 numel(self.input_tensor) // mbsize,
230 (numel(self.input_tensor) + numel(ref)) // mbsize
231 ],
232 )),
233 dims=ref.shape[1:])
234
235 # Store reference
236 self.reference = refnode
237 self.reference_tensor = ref
238 return self.reference
239
240 def set_check_gradients_tensor(self, tensor: lbann.Layer):
241 """

Callers 15

test_inplace_viewFunction · 0.95
setup_testerFunction · 0.95
test_select_operatorFunction · 0.95
test_select_all_constantFunction · 0.95
test_multihead_attentionFunction · 0.95
test_self_attentionFunction · 0.95
test_layernorm_basicFunction · 0.95

Calls 1

numelFunction · 0.85

Tested by

no test coverage detected