Esempio n. 1
0
 public string GetBufferName(BufferInfo buffer)
 {
     if (buffer == null)
     {
         return(null);
     }
     else if (buffer.IsShared)
     {
         if (Scope.Contains(buffer.Name))
         {
             return(buffer.Name);
         }
         string shared;
         if (buffer.Content == typeof(NumNet.Array <int>))
         {
             shared = "IntArray";
         }
         else if (buffer.Content == typeof(NumNet.Array <float>))
         {
             shared = "FloatArray";
         }
         else
         {
             throw new NotImplementedException("Doesn't support shared of type: " + buffer.Content);
         }
         return($"{shared}[\"{buffer.Name}\"]");
     }
     else if (buffer.IsResizable)
     {
         lockDecount = true;
         CompileExpr(buffer.Shape, new CodeGenerator());
         lockDecount = false;
         var shape = $"{string.Join(", ", buffer.Shape.Select(axis => Scope.GetVar(axis)))}";
         return(buffer.Name + $".ResizeTo({shape})");
     }
     else
     {
         return(buffer.Name);
     }
 }