def _write_shape(self, tensor_name, tensor_value, save_collections, tensor_ref=None): writers = self._get_writers(tensor_name, tensor_ref=tensor_ref) for s_col in save_collections: reduction_config = s_col.reduction_config if self.dry_run is False and reduction_config.save_shape is True: numpy_tensor_value = self._make_numpy_array(tensor_value) this_size, this_shape = size_and_shape(numpy_tensor_value) # In TF Keras and Variables in all interfaces of TF, sometimes we output tensors with # more meaningful names than the origina name. Outputting # both Smdebug given name and original name in such cases if tensor_ref is not None and tensor_ref.tf_obj is not None: original_name = tensor_ref.tf_obj.name else: original_name = None for writer in writers: writer.write_shape( tensor_name, this_shape, self.mode, self.mode_steps[self.mode], original_name=original_name, ) break
def _write_raw_tensor_simple(self, tensor_name, tensor_value, tensor_ref=None): # tensor_ref is used by TF # todo: if fp16, check perf of saving as fp16 in proto vs as fp32 numpy_tensor_value = self._make_numpy_array(tensor_value) this_size, this_shape = size_and_shape(numpy_tensor_value) if self.dry_run is False and this_size > 0: writers = self._get_writers(tensor_name, tensor_ref=tensor_ref) for writer in writers: writer.write_tensor( tdata=numpy_tensor_value, tname=tensor_name, mode=self.mode, mode_step=self.mode_steps[self.mode], )
def _write_shape(self, tensor_name, tensor_value, save_collections, tensor_ref=None): shape_writers = self._get_writers(tensor_name, tensor_ref=tensor_ref, shape_writers=True) for s_col in save_collections: reduction_config = s_col.reduction_config if self.dry_run is False and reduction_config.save_shape is True: numpy_tensor_value = self._make_numpy_array(tensor_value) this_size, this_shape = size_and_shape(numpy_tensor_value) if tensor_ref is not None and tensor_ref.tf_obj is not None: original_name = tensor_ref.tf_obj.name else: original_name = None for writer in shape_writers: writer.write_shape( tensor_name, this_shape, self.mode, self.mode_steps[self.mode], original_name=original_name, ) break