unsafe IntPtr IOperatorDescriptionMarshal.__MarshalAlloc() { __Native * @ref = UnsafeUtilities.Alloc <__Native>(); @ref->InputTensor = InputTensor.__MarshalAlloc(); @ref->WeightTensor = WeightTensor.__MarshalAlloc(); @ref->RecurrenceTensor = RecurrenceTensor.__MarshalAlloc(); @ref->BiasTensor = (BiasTensor != null) ? BiasTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->HiddenInitializerTensor = (HiddenInitializerTensor != null) ? HiddenInitializerTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->SequenceLengthsTensor = (SequenceLengthsTensor != null) ? SequenceLengthsTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->OutputSequenceTensor = (OutputSequenceTensor != null) ? OutputSequenceTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->OutputSingleTensor = (OutputSingleTensor != null) ? OutputSingleTensor.Value.__MarshalAlloc() : IntPtr.Zero; @ref->ActivationDescCount = Activations.Length; @ref->Activations = IntPtr.Zero; if (Activations.Length != 0) { var activationDescsPtr = UnsafeUtilities.Alloc <OperatorDescription.__Native>(Activations.Length); for (int i = 0; i < Activations.Length; i++) { Activations[i].__MarshalTo(ref activationDescsPtr[i]); } @ref->Activations = new(activationDescsPtr); } @ref->Direction = Direction; return(new(@ref)); }
unsafe void IOperatorDescriptionMarshal.__MarshalFree(ref IntPtr pDesc) { var @ref = (__Native *)pDesc; InputTensor.__MarshalFree(ref @ref->InputTensor); WeightTensor.__MarshalFree(ref @ref->WeightTensor); RecurrenceTensor.__MarshalFree(ref @ref->RecurrenceTensor); if (BiasTensor != null) { BiasTensor.Value.__MarshalFree(ref @ref->BiasTensor); } if (HiddenInitializerTensor != null) { HiddenInitializerTensor.Value.__MarshalFree(ref @ref->HiddenInitializerTensor); } if (SequenceLengthsTensor != null) { SequenceLengthsTensor.Value.__MarshalFree(ref @ref->SequenceLengthsTensor); } if (OutputSequenceTensor != null) { OutputSequenceTensor.Value.__MarshalFree(ref @ref->OutputSequenceTensor); } if (OutputSingleTensor != null) { OutputSingleTensor.Value.__MarshalFree(ref @ref->OutputSingleTensor); } if (@ref->Activations != IntPtr.Zero) { var activationDescsPtr = (OperatorDescription.__Native *)@ref->Activations; for (int i = 0; i < Activations.Length; i++) { Activations[i].__MarshalFree(ref activationDescsPtr[i]); } UnsafeUtilities.Free(@ref->Activations); } UnsafeUtilities.Free(@ref); }