Ejemplo n.º 1
0
 public void Add_(IExpr expr, IExpr value)
 {
     if (expr is ITensor tensor && PreserveShape)
     {
         if (!ShapeExtension.CanEqualTo((value as ITensor).Shape, tensor.Shape))
         {
             throw new ArgumentException($"Can't patch {expr} with {value}");
         }
     }
     _substitutions[expr] = value;
 }
Ejemplo n.º 2
0
        public static void AssertOfShape <T>(this ITensor <T> thiz, params Scalar <int>[] shape)
        {
            var a = thiz.Shape;

            if (thiz.NDim != shape.Length)
            {
                throw RankException("{0} of shape {1}, won't match with: {2}", thiz, thiz.Shape.Format(thiz), shape.Format(thiz));
            }

            for (int d = 0; d < thiz.NDim; ++d)
            {
                if (!ShapeExtension.CanEqualTo(a[d], shape[d]))
                {
                    throw RankException("{0} of shape {1}, won't match with: {2}", thiz, thiz.Shape.Format(thiz), shape.Format(thiz));
                }
            }
        }