Example #1
0
            public TransformInfo(IHost host, ColumnInfo column, int d, float avgDist)
            {
                Contracts.AssertValue(host);

                SrcDim = d;
                NewDim = column.NewDim;
                host.CheckUserArg(NewDim > 0, nameof(column.NewDim));
                _useSin = column.UseSin;
                var seed = column.Seed;

                _rand  = seed.HasValue ? RandomUtils.Create(seed) : RandomUtils.Create(host.Rand);
                _state = _rand.GetState();

                var generator = column.Generator;

                _matrixGenerator = generator.CreateComponent(host, avgDist);

                int roundedUpD           = RoundUp(NewDim, _cfltAlign);
                int roundedUpNumFeatures = RoundUp(SrcDim, _cfltAlign);

                RndFourierVectors = new AlignedArray(roundedUpD * roundedUpNumFeatures, CpuMathUtils.GetVectorAlignment());
                RotationTerms     = _useSin ? null : new AlignedArray(roundedUpD, CpuMathUtils.GetVectorAlignment());

                InitializeFourierCoefficients(roundedUpNumFeatures, roundedUpD);
            }
            public TransformInfo(IHost host, Column item, Arguments args, int d, Float avgDist)
            {
                Contracts.AssertValue(host);

                SrcDim = d;
                NewDim = item.NewDim ?? args.NewDim;
                host.CheckUserArg(NewDim > 0, nameof(item.NewDim));
                _useSin = item.UseSin ?? args.UseSin;
                var seed = item.Seed ?? args.Seed;

                _rand  = seed.HasValue ? RandomUtils.Create(seed) : RandomUtils.Create(host.Rand);
                _state = _rand.GetState();

                var generator = item.MatrixGenerator;

                if (generator == null)
                {
                    generator = args.MatrixGenerator;
                }
                _matrixGenerator = generator.CreateComponent(host, avgDist);

                int roundedUpD           = RoundUp(NewDim, CfltAlign);
                int roundedUpNumFeatures = RoundUp(SrcDim, CfltAlign);

                RndFourierVectors = new AlignedArray(roundedUpD * roundedUpNumFeatures, CpuMathUtils.Vector128Alignment);
                RotationTerms     = _useSin ? null : new AlignedArray(roundedUpD, CpuMathUtils.Vector128Alignment);

                InitializeFourierCoefficients(roundedUpNumFeatures, roundedUpD);
            }