function tensorMinMax(tensor) {
  let min = Infinity
  let max = -Infinity
  for (let i = 0, len = tensor.data.length; i < len; i++) {
    if (tensor.data[i] < min) min = tensor.data[i]
    if (tensor.data[i] > max) max = tensor.data[i]
  }
  return { min, max }
}
calculates min and max for a ndarray tensor