MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _get_tensor_details

Method _get_tensor_details

tensorflow/lite/python/interpreter.py:274–303  ·  view source on GitHub ↗

Gets tensor details. Args: tensor_index: Tensor index of tensor to query. Returns: a dictionary containing the name, index, shape and type of the tensor. Raises: ValueError: If tensor_index is invalid.

(self, tensor_index)

Source from the content-addressed store, hash-verified

272 data access.""")
273
274 def _get_tensor_details(self, tensor_index):
275 """Gets tensor details.
276
277 Args:
278 tensor_index: Tensor index of tensor to query.
279
280 Returns:
281 a dictionary containing the name, index, shape and type of the tensor.
282
283 Raises:
284 ValueError: If tensor_index is invalid.
285 """
286 tensor_index = int(tensor_index)
287 tensor_name = self._interpreter.TensorName(tensor_index)
288 tensor_size = self._interpreter.TensorSize(tensor_index)
289 tensor_type = self._interpreter.TensorType(tensor_index)
290 tensor_quantization = self._interpreter.TensorQuantization(tensor_index)
291
292 if not tensor_name or not tensor_type:
293 raise ValueError('Could not get tensor details')
294
295 details = {
296 'name': tensor_name,
297 'index': tensor_index,
298 'shape': tensor_size,
299 'dtype': tensor_type,
300 'quantization': tensor_quantization,
301 }
302
303 return details
304
305 def get_tensor_details(self):
306 """Gets tensor details for every tensor with valid tensor details.

Callers 4

get_tensor_detailsMethod · 0.95
get_input_detailsMethod · 0.95
get_output_detailsMethod · 0.95
testInvalidIndexMethod · 0.95

Calls 4

TensorNameMethod · 0.80
TensorSizeMethod · 0.80
TensorTypeMethod · 0.80
TensorQuantizationMethod · 0.80

Tested by 1

testInvalidIndexMethod · 0.76