unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->Axis = Axis; @ref->AxisDirection = AxisDirection; @ref->HasExclusiveProduct = HasExclusiveProduct; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->Scale = Scale; @ref->ChannelCount = Bias.Length; @ref->Bias = new(UnsafeUtilities.AllocWithData(Bias)); return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->OutputValueTensor = OutputValueTensor.__MarshalAlloc(); @ref->OutputIndexTensor = OutputIndexTensor.__MarshalAlloc(); @ref->Axis = Axis; @ref->K = K; return(new(@ref)); }
unsafe IntPtr IStateSubObjectDescriptionMarshal.__MarshalAlloc(Dictionary <StateSubObject, IntPtr> subObjectLookup) { __Native *native = (__Native *)Marshal.AllocHGlobal(sizeof(__Native)); DxilLibrary.__MarshalTo(ref native->DXILLibrary); native->NumExports = Exports?.Length ?? 0; if (native->NumExports > 0) { var nativeExports = (ExportDescription.__Native *)UnsafeUtilities.Alloc <ExportDescription.__Native>(native->NumExports); for (int i = 0; i < native->NumExports; i++) { Exports ![i].__MarshalTo(ref nativeExports[i]);
unsafe IntPtr IStateSubObjectDescriptionMarshal.__MarshalAlloc(Dictionary <StateSubObject, IntPtr> subObjectLookup) { __Native *native = (__Native *)Marshal.AllocHGlobal(sizeof(__Native)); native->pExistingCollection = MarshallingHelpers.ToCallbackPtr <ID3D12StateObject>(ExistingCollection); native->NumExports = Exports?.Length ?? 0; if (native->NumExports > 0) { var nativeExports = (ExportDescription.__Native *)UnsafeUtilities.Alloc <ExportDescription.__Native>(native->NumExports); for (int i = 0; i < native->NumExports; i++) { Exports ![i].__MarshalTo(ref nativeExports[i]);
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->InputGradientTensor = InputGradientTensor.__MarshalAlloc(); @ref->OutputGradientTensor = OutputGradientTensor.__MarshalAlloc(); @ref->Minimum = Minimum; @ref->Maximum = Maximum; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->ATensor = ATensor.__MarshalAlloc(); @ref->AZeroPointTensor = (AZeroPointTensor != null) ? AZeroPointTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->BTensor = BTensor.__MarshalAlloc(); @ref->BZeroPointTensor = (BZeroPointTensor != null) ? BZeroPointTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->OutputTensor = OutputTensor.__MarshalAlloc(); return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->Function = Function; @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->AxisCount = Axes.Length; @ref->Axes = new(UnsafeUtilities.AllocWithData(Axes)); return(new(@ref)); }
unsafe IntPtr IStateSubObjectDescriptionMarshal.__MarshalAlloc(Dictionary <StateSubObject, IntPtr> subObjectLookup) { __Native *native = (__Native *)Marshal.AllocHGlobal(sizeof(__Native)); native->pSubobjectToAssociate = Marshal.StringToHGlobalUni(SubObjectToAssociate); native->NumExports = Exports?.Length ?? 0; if (native->NumExports > 0) { var nativeExports = (IntPtr *)Marshal.AllocHGlobal(IntPtr.Size * native->NumExports); for (int i = 0; i < native->NumExports; i++) { nativeExports[i] = Marshal.StringToHGlobalUni(Exports ![i]);
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->RoiTensor = RoiTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->SpatialScale = SpatialScale; @ref->PooledSize = PooledSize; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->IndicesTensor = IndicesTensor.__MarshalAlloc(); @ref->UpdatesTensor = UpdatesTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->InputDimensionCount = InputDimensionCount; @ref->IndicesDimensionCount = IndicesDimensionCount; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->ScaleBias = (ScaleBias != null) ? new(UnsafeUtilities.AllocWithData(ScaleBias.Value)) : IntPtr.Zero; @ref->MinMaxDataType = MinMaxDataType; @ref->Minimum = Minimum; @ref->Maximum = Maximum; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->CrossChannel = CrossChannel; @ref->LocalSize = LocalSize; @ref->Alpha = Alpha; @ref->Beta = Beta; @ref->Bias = Bias; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->ScaleTensor = (ScaleTensor != null) ? ScaleTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->BiasTensor = (BiasTensor != null) ? BiasTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->CrossChannel = CrossChannel; @ref->NormalizeVariance = NormalizeVariance; @ref->Epsilon = Epsilon; @ref->FusedActivation = (FusedActivation != null) ? FusedActivation.Value.__MarshalAlloc() : IntPtr.Zero; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->ATensor = ATensor.__MarshalAlloc(); @ref->BTensor = BTensor.__MarshalAlloc(); @ref->CTensor = (CTensor != null) ? CTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->TransformA = TransformA; @ref->TransformB = TransformB; @ref->Alpha = Alpha; @ref->Beta = Beta; @ref->FusedActivation = (FusedActivation != null) ? FusedActivation.Value.__MarshalAlloc() : IntPtr.Zero; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->MeanTensor = MeanTensor.__MarshalAlloc(); @ref->VarianceTensor = VarianceTensor.__MarshalAlloc(); @ref->ScaleTensor = ScaleTensor.__MarshalAlloc(); @ref->BiasTensor = BiasTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->Spatial = Spatial; @ref->Epsilon = Epsilon; @ref->FusedActivation = (FusedActivation != null) ? FusedActivation.Value.__MarshalAlloc() : IntPtr.Zero; return(new(@ref)); }
unsafe IntPtr IBindingDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); BufferBinding.__Native *bindings = UnsafeUtilities.Alloc <BufferBinding.__Native>(Bindings.Length); for (int i = 0; i < Bindings.Length; i++) { Bindings[i].__MarshalTo(ref bindings[i]); } @ref->Count = (uint)Bindings.Length; @ref->Bindings = new(bindings); return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->InputGradientTensor = InputGradientTensor.__MarshalAlloc(); @ref->MeanTensor = MeanTensor.__MarshalAlloc(); @ref->VarianceTensor = VarianceTensor.__MarshalAlloc(); @ref->ScaleTensor = ScaleTensor.__MarshalAlloc(); @ref->OutputGradientTensor = OutputGradientTensor.__MarshalAlloc(); @ref->OutputScaleGradientTensor = OutputScaleGradientTensor.__MarshalAlloc(); @ref->OutputBiasGradientTensor = OutputBiasGradientTensor.__MarshalAlloc(); @ref->Epsilon = Epsilon; return(new(@ref)); }
private unsafe void Deserialize(IntPtr pNativePtr) { if (pNativePtr == IntPtr.Zero) { return; } __Native *pNative = (__Native *)pNativePtr; if (pNative->ParameterCount > 0) { Parameters = new RootParameter[pNative->ParameterCount]; RootParameter.__Native *rpn = (RootParameter.__Native *)pNative->ParametersPointer; for (int i = 0; i < Parameters.Length; ++i) { Parameters[i] = new RootParameter(); if (rpn[i].ParameterType == RootParameterType.DescriptorTable) { // Marshal descriptor table DescriptorRange[] ranges = null; int rangeCount = rpn[i].Union.DescriptorTable.DescriptorRangeCount; if (rangeCount > 0) { ranges = new DescriptorRange[rangeCount]; Utilities.Read(rpn[i].Union.DescriptorTable.DescriptorRangesPointer, ranges, 0, ranges.Length); } Parameters[i] = new RootParameter(rpn[i].ShaderVisibility, ranges); } else { // No need to marshal them when RootParameter don't contain DescriptorTable - simple copy as-is Parameters[i] = new RootParameter { native = *rpn }; } } } if (pNative->StaticSamplerCount > 0) { StaticSamplers = new StaticSamplerDescription[pNative->StaticSamplerCount]; Utilities.Read(pNative->StaticSamplerPointer, StaticSamplers, 0, StaticSamplers.Length); } }
unsafe IntPtr IStateSubObjectDescriptionMarshal.__MarshalAlloc(Dictionary <StateSubObject, IntPtr> subObjectLookup) { __Native *native = (__Native *)Marshal.AllocHGlobal(sizeof(__Native)); if (subObjectLookup.ContainsKey(SubObjectToAssociate) == false) { throw new InvalidOperationException("Associated StateSubObject must be a reference to an element of the array in StateObjectDescription"); } native->pSubobjectToAssociate = (StateSubObject.__Native *)subObjectLookup[SubObjectToAssociate].ToPointer(); native->NumExports = Exports?.Length ?? 0; if (native->NumExports > 0) { var nativeExports = (IntPtr *)Marshal.AllocHGlobal(IntPtr.Size * native->NumExports); for (int i = 0; i < native->NumExports; i++) { nativeExports[i] = Marshal.StringToHGlobalUni(Exports ![i]);
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->RoiTensor = RoiTensor.__MarshalAlloc(); @ref->BatchIndicesTensor = BatchIndicesTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->ReductionFunction = ReductionFunction; @ref->InterpolationMode = InterpolationMode; @ref->SpatialScaleX = SpatialScaleX; @ref->SpatialScaleY = SpatialScaleY; @ref->OutOfBoundsInputValue = OutOfBoundsInputValue; @ref->MinimumSamplesPerOutput = MinimumSamplesPerOutput; @ref->MaximumSamplesPerOutput = MaximumSamplesPerOutput; return(new(@ref)); }
unsafe IntPtr IStateSubObjectDescriptionMarshal.__MarshalAlloc(Dictionary <StateSubObject, IntPtr> subObjectLookup) { __Native *native = (__Native *)Marshal.AllocHGlobal(sizeof(__Native)); native->pExistingCollection = CppObject.ToCallbackPtr <ID3D12StateObject>(ExistingCollection); native->NumExports = Exports?.Length ?? 0; if (native->NumExports > 0) { var nativeExports = (ExportDescription.__Native *)Interop.Alloc <ExportDescription.__Native>(native->NumExports); for (int i = 0; i < native->NumExports; i++) { Exports[i].__MarshalTo(ref nativeExports[i]); } native->pExports = nativeExports; } return((IntPtr)native); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputParametersTensor = InputParametersTensor.__MarshalAlloc(); @ref->InputFirstMomentTensor = InputFirstMomentTensor.__MarshalAlloc(); @ref->InputSecondMomentTensor = InputSecondMomentTensor.__MarshalAlloc(); @ref->GradientTensor = GradientTensor.__MarshalAlloc(); @ref->TrainingStepTensor = TrainingStepTensor.__MarshalAlloc(); @ref->OutputParametersTensor = OutputParametersTensor.__MarshalAlloc(); @ref->OutputFirstMomentTensor = OutputFirstMomentTensor.__MarshalAlloc(); @ref->OutputSecondMomentTensor = OutputSecondMomentTensor.__MarshalAlloc(); @ref->LearningRate = LearningRate; @ref->Beta1 = Beta1; @ref->Beta2 = Beta2; @ref->Epsilon = Epsilon; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->FilterTensor = FilterTensor.__MarshalAlloc(); @ref->BiasTensor = (BiasTensor != null) ? BiasTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->Mode = Mode; @ref->Direction = Direction; var dimensionCount = Strides.Length; if (Dilations.Length != dimensionCount) { throw new IndexOutOfRangeException("Dilations must have the same length as Strides."); } if (StartPadding.Length != dimensionCount) { throw new IndexOutOfRangeException("StartPadding must have the same length as Strides."); } if (EndPadding.Length != dimensionCount) { throw new IndexOutOfRangeException("EndPadding must have the same length as Strides."); } if (OutputPadding.Length != dimensionCount) { throw new IndexOutOfRangeException("OutputPadding must have the same length as Strides."); } @ref->DimensionCount = dimensionCount; @ref->Strides = new(UnsafeUtilities.AllocWithData(Strides)); @ref->Dilations = new(UnsafeUtilities.AllocWithData(Dilations)); @ref->StartPadding = new(UnsafeUtilities.AllocWithData(StartPadding)); @ref->EndPadding = new(UnsafeUtilities.AllocWithData(EndPadding)); @ref->OutputPadding = new(UnsafeUtilities.AllocWithData(OutputPadding)); @ref->GroupCount = GroupCount; @ref->FusedActivation = (FusedActivation != null) ? FusedActivation.Value.__MarshalAlloc() : IntPtr.Zero; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputCount = InputTensors.Length; @ref->InputTensors = IntPtr.Zero; if (InputTensors.Length != 0) { var inputTensorsPtr = UnsafeUtilities.Alloc <TensorDescription.__Native>(InputTensors.Length); for (int i = 0; i < InputTensors.Length; i++) { InputTensors[i].__MarshalTo(ref inputTensorsPtr[i]); } @ref->InputTensors = new(inputTensorsPtr); } @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->Axis = Axis; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = (InputTensor != null) ? InputTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->InputGradientTensor = InputGradientTensor.__MarshalAlloc(); @ref->RoiTensor = RoiTensor.__MarshalAlloc(); @ref->BatchIndicesTensor = BatchIndicesTensor.__MarshalAlloc(); @ref->OutputGradientTensor = (OutputGradientTensor != null) ? OutputGradientTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->OutputROIGradientTensor = (OutputROIGradientTensor != null) ? OutputROIGradientTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->ReductionFunction = ReductionFunction; @ref->InterpolationMode = InterpolationMode; @ref->SpatialScaleX = SpatialScaleX; @ref->SpatialScaleY = SpatialScaleY; @ref->InputPixelOffset = InputPixelOffset; @ref->OutputPixelOffset = OutputPixelOffset; @ref->MinimumSamplesPerOutput = MinimumSamplesPerOutput; @ref->MaximumSamplesPerOutput = MaximumSamplesPerOutput; @ref->AlignRegionsToCorners = AlignRegionsToCorners; return(new(@ref)); }
unsafe IntPtr ITensorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->DataType = DataType; @ref->Flags = Flags; @ref->DimensionCount = Sizes.Length; @ref->PSizes = UnsafeUtilities.AllocToPointer(Sizes); @ref->PStrides = IntPtr.Zero; if (Strides != null) { if (Strides.Length != Sizes.Length) { throw new IndexOutOfRangeException("Strides must have the same length as Sizes."); } @ref->PStrides = UnsafeUtilities.AllocToPointer(Strides); } @ref->TotalTensorSizeInBytes = TotalTensorSizeInBytes; @ref->GuaranteedBaseOffsetAlignment = GuaranteedBaseOffsetAlignment; return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->OutputTensor = OutputTensor.__MarshalAlloc(); @ref->PaddingMode = PaddingMode; @ref->PaddingValue = PaddingValue; var dimensionCount = StartPadding.Length; if (EndPadding.Length != dimensionCount) { throw new IndexOutOfRangeException("EndPadding must have the same length as StartPadding."); } @ref->DimensionCount = dimensionCount; @ref->StartPadding = new(UnsafeUtilities.AllocWithData(StartPadding)); @ref->EndPadding = new(UnsafeUtilities.AllocWithData(EndPadding)); return(new(@ref)); }
unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->InputGradientTensor = InputGradientTensor.__MarshalAlloc(); @ref->OutputGradientTensor = OutputGradientTensor.__MarshalAlloc(); var dimensionCount = Strides.Length; if (WindowSize.Length != dimensionCount) { throw new IndexOutOfRangeException("WindowSize must have the same length as Strides."); } if (StartPadding.Length != dimensionCount) { throw new IndexOutOfRangeException("StartPadding must have the same length as Strides."); } if (EndPadding.Length != dimensionCount) { throw new IndexOutOfRangeException("EndPadding must have the same length as Strides."); } if (Dilations.Length != dimensionCount) { throw new IndexOutOfRangeException("Dilations must have the same length as Strides."); } @ref->DimensionCount = dimensionCount; @ref->Strides = new(UnsafeUtilities.AllocWithData(Strides)); @ref->WindowSize = new(UnsafeUtilities.AllocWithData(WindowSize)); @ref->StartPadding = new(UnsafeUtilities.AllocWithData(StartPadding)); @ref->EndPadding = new(UnsafeUtilities.AllocWithData(EndPadding)); @ref->Dilations = new(UnsafeUtilities.AllocWithData(Dilations)); return(new(@ref)); }