コード例 #1
0
        public override void CheckInputShapes(params Shape[] inshapes)
        {
            base.CheckInputShapes(inshapes);

            if (inshapes.Select((shape) => shape.Ndim).Any((ndim) => ndim <= Axis))
            {
                throw new ArgumentOutOfRangeException(nameof(Axis));
            }

            for (int i = 1; i < inshapes.Length; i++)
            {
                if (inshapes[i].Ndim != inshapes[0].Ndim)
                {
                    throw new ArgumentException(ExceptionMessage.Concat(Axis, inshapes));
                }

                for (int j = 0; j < inshapes[0].Ndim; j++)
                {
                    if (j == Axis)
                    {
                        continue;
                    }

                    if (inshapes[i][j] != inshapes[0][j])
                    {
                        throw new ArgumentException(ExceptionMessage.Concat(Axis, inshapes));
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>コンストラクタ</summary>
        public Concat(Shape[] inshapes, Shape outshape, int axis)
        {
            if (!CheckShape(inshapes, outshape, axis))
            {
                throw new ArgumentException(ExceptionMessage.Concat(axis, inshapes, outshape));
            }

            this.arguments = inshapes.Select((shape) => (ArgumentType.In, shape)).ToList();
            this.arguments.Add((ArgumentType.Out, outshape));

            this.in_strides = new uint[inshapes.Length];
            this.out_stride = 0;

            for (int i = 0; i < inshapes.Length; i++)
            {
                in_strides[i] = 1;
                for (int j = 0; j <= axis; j++)
                {
                    in_strides[i] *= (uint)inshapes[i][j];
                }

                out_stride += in_strides[i];
            }
        }