/// <summary> /// Returns the shape of the Tensor /// </summary> /// <param name="output">The output</param> /// <param name="status">The status</param> /// <returns>The shape of the Tensor</returns> public int[] GetTensorShape(Output output, Status status = null) { using (StatusChecker checker = new StatusChecker(status)) { int numDim = TfInvoke.tfeGraphGetTensorNumDims(_ptr, output.Operation, output.Index, checker.Status); if (numDim < 0) { return(null); } else if (numDim == 0) { return(new int[0]); } int[] dims = new int[numDim]; GCHandle handle = GCHandle.Alloc(dims, GCHandleType.Pinned); TfInvoke.tfeGraphGetTensorShape(_ptr, output.Operation, output.Index, handle.AddrOfPinnedObject(), numDim, checker.Status); handle.Free(); return(dims); } }