Exemplo n.º 1
0
 /// <summary>
 /// Bind external allocation as input or output.
 /// The allocation is owned by the user code.
 /// </summary>
 /// <param name="name">name </param>
 /// <param name="allocation">non ort allocated memory</param>
 /// <param name="isInput">whether this is an input or output</param>
 private void BindExternalAllocation(string name, OrtExternalAllocation allocation, bool isInput)
 {
     using (var ortValue = OrtValue.CreateTensorValueWithData(allocation.Info,
                                                              allocation.ElementType,
                                                              allocation.Shape,
                                                              allocation.Pointer,
                                                              allocation.Size))
         BindInputOrOutput(name, ortValue.Handle, isInput);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Bind externally (not from OrtAllocator) allocated memory as input.
 /// The model will read the specified input from that memory
 /// possibly avoiding the need to copy between devices. The user code continues to own
 /// the chunk of externally allocated memory, and the allocation should be alive until the end of execution.
 /// </summary>
 /// <param name="name">name</param>
 /// <param name="allocation">non ort allocated memory</param>
 public void BindInput(string name, OrtExternalAllocation allocation)
 {
     BindExternalAllocation(name, allocation, true);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Bind externally (not from OrtAllocator) allocated memory as output.
 /// The model will read the specified input from that memory
 /// possibly avoiding the need to copy between devices. The user code continues to own
 /// the chunk of externally allocated memory, and the allocation should be alive until the end of execution.
 /// </summary>
 /// <param name="name">name</param>
 /// <param name="allocation">non ort allocated memory</param>
 public void BindOutput(string name, OrtExternalAllocation allocation)
 {
     BindExternalAllocation(name, allocation, false);
 }