public NDArray build_results(BaseSession session, NDArray[] tensor_values) { var full_values = new List <object>(); if (_final_fetches.Count != tensor_values.Length) { throw new InvalidOperationException("_final_fetches mismatch tensor_values"); } int i = 0; int j = 0; foreach (var is_op in _ops) { if (is_op) { full_values.Add(null); } else { var value = tensor_values[j]; j += 1; full_values.Add(value); } i += 1; } if (j != tensor_values.Length) { throw new InvalidOperationException("j mismatch tensor_values"); } return(_fetch_mapper.build_results(full_values)); }
public NDArray build_results(BaseSession session, NDArray[] tensor_values) { var full_values = new List <object>(); if (_final_fetches.Count != tensor_values.Length) { throw new InvalidOperationException("_final_fetches mismatch tensor_values"); } int i = 0; int j = 0; foreach (var is_op in _ops) { if (is_op) { full_values.Add(null); } else { var value = tensor_values[j]; j += 1; switch (value.dtype.Name) { case "Int32": full_values.Add(value.Data <int>(0)); break; case "Single": full_values.Add(value.Data <float>(0)); break; case "Double": full_values.Add(value.Data <double>(0)); break; } } i += 1; } if (j != tensor_values.Length) { throw new InvalidOperationException("j mismatch tensor_values"); } return(_fetch_mapper.build_results(full_values)); }
public NDArray build_results(BaseSession session, NDArray[] tensor_values) { var full_values = new List <NDArray>(); if (_final_fetches.Count != tensor_values.Length) { throw new InvalidOperationException("_final_fetches mismatch tensor_values"); } int i = 0; int j = 0; foreach (var is_op in _ops) { if (is_op) { if (tensor_values.Length > 0) { switch (tensor_values[0].dtype.Name) { case "Int32": full_values.Add(float.NaN); break; case "Single": full_values.Add(float.NaN); break; case "String": full_values.Add(float.NaN); break; default: throw new NotImplementedException($"build_results tensor_values[0] {tensor_values[0].dtype.Name}"); } } else { full_values.Add(null); } } else { var value = tensor_values[j]; j += 1; if (value.ndim == 0) { switch (value.dtype.Name) { case "Int32": full_values.Add(value.Data <int>(0)); break; case "Int64": full_values.Add(value.Data <long>(0)); break; case "Single": full_values.Add(value.Data <float>(0)); break; case "Double": full_values.Add(value.Data <double>(0)); break; case "String": full_values.Add(value.Data <string>(0)); break; } } else { full_values.Add(value[np.arange(0, value.shape[0])]); } } i += 1; } if (j != tensor_values.Length) { throw new InvalidOperationException("j mismatch tensor_values"); } return(_fetch_mapper.build_results(full_values)); }
public NDArray[] build_results(BaseSession session, NDArray[] tensor_values) { var full_values = new List <NDArray>(); if (_final_fetches.Count != tensor_values.Length) { throw new InvalidOperationException("_final_fetches mismatch tensor_values"); } int i = 0; int j = 0; foreach (var is_op in _ops) { if (is_op) { if (tensor_values.Length > 0) { switch (tensor_values[0].typecode) { case NPTypeCode.Int32: full_values.Add(float.NaN); break; case NPTypeCode.Single: full_values.Add(float.NaN); break; case NPTypeCode.Double: full_values.Add(float.NaN); break; case NPTypeCode.String: full_values.Add(float.NaN); break; case NPTypeCode.Char: full_values.Add(float.NaN); break; case NPTypeCode.Byte: full_values.Add(float.NaN); break; default: throw new NotImplementedException($"build_results tensor_values[0] {tensor_values[0].dtype.Name}"); } } else { full_values.Add(null); } } else { var value = tensor_values[j]; j += 1; if (value.ndim == 0) { switch (value.typecode) { case NPTypeCode.Int16: full_values.Add(value.GetValue <short>(0)); break; case NPTypeCode.Int32: full_values.Add(value.GetValue <int>(0)); break; case NPTypeCode.Int64: full_values.Add(value.GetValue <long>(0)); break; case NPTypeCode.Single: full_values.Add(value.GetValue <float>(0)); break; case NPTypeCode.Double: full_values.Add(value.GetValue <double>(0)); break; /*case "String": * full_values.Add(value.Data<byte>()[0]); * break;*/ default: throw new NotImplementedException($"build_results tensor_values[0] {tensor_values[0].dtype.Name}"); } } else { full_values.Add(value[np.arange(0, value.shape[0])]); } } i += 1; } if (j != tensor_values.Length) { throw new InvalidOperationException("j mismatch tensor_values"); } return(_fetch_mapper.build_results(full_values)); }