Backends/SiaNet.Backend.TensorSharp/Cpu/CpuStorage.cs
/// <summary>
/// Sets the element as float.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="value">The value.</param>
/// <exception cref="NotSupportedException">Element type " + ElementType + " not supported</exception>
Sets the element as float.
Sets the element as float .
public override void SetElementAsFloat(long index, float value)
        {
            unsafe
            {
                if(ElementType == DType.Float32) ((float*)buffer.ToPointer())[index] = value;
                else if (ElementType == DType.Float64) ((double*)buffer.ToPointer())[index] = value;
                else if (ElementType == DType.Int32) ((int*)buffer.ToPointer())[index] = (int)value;
                else if (ElementType == DType.UInt8) ((byte*)buffer.ToPointer())[index] = (byte)value;
                else
                    throw new NotSupportedException("Element type " + ElementType + " not supported");
            }
        }
public override void SetElementAsFloat ( long index , float value ) { unsafe { if ( ElementType == DType . Float32 ) ( ( float * ) buffer . ToPointer ( ) ) [ index ] = value ; else if ( ElementType == DType . Float64 ) ( ( double * ) buffer . ToPointer ( ) ) [ index ] = value ; else if ( ElementType == DType . Int32 ) ( ( int * ) buffer . ToPointer ( ) ) [ index ] = ( int ) value ; else if ( ElementType == DType . UInt8 ) ( ( byte * ) buffer . ToPointer ( ) ) [ index ] = ( byte ) value ; else throw new NotSupportedException ( " " + ElementType + " " ) ; } }
Sets the element as float.
Sets the element as float .
Element type " + ElementType + " not supported
Element type " + ElementType + " not supported
index
long
None
value
float
None