hi,

it all depends on how you are declaring your types.

here, for example you are passing 

aTF_OutputArray getHandle

that’s a “void*” value (an ExternalAddress or ExternalData object), and in 
declaration you have (if I read correctly):

TF_Output * 

so, first question is: if TF_Output != void, then you have a coercing problem 
:).

you can fix that just changing the notation to receive a void * (in C is all 
the same, but not in pharo :)) 

note that this can be happening in a lot of places, since your function has a 
lot of arguments, I just put an example of what can be wrong. 

cheers, 
Esteban


> On 27 Apr 2018, at 11:23, Serge Stinckwich <serge.stinckw...@gmail.com> wrote:
> 
> I would like to pass a pointer to an array of pointers to a FFI call and I 
> have problems ...
> 
> ​I have this method:
> 
> runOutputs: aTF_OutputArray size: anInteger
>     | status outvalues |
>     status := TF_Status create.
>     outvalues := FFIExternalArray externalNewType: 'TF_Tensor*' size: 
> anInteger.
>     self library
>         runSession: self
>         options: FFIExternalObject null
>         inputs: FFIExternalObject null
>         values: FFIExternalObject null
>         count: 0
>         outputs: aTF_OutputArray getHandle
>         values: outvalues getHandle
>         count: anInteger
>         targets: FFIExternalObject null
>         count: 0
>         metadata: FFIExternalObject null
>         status: status.
>     status check.
>     ^ outvalues
> 
> ​the FFI call is like that : 
> 
> runSession: aTF_Session
>     options: opsTF_Buffer
>     inputs: inTF_OutputArray values: inTF_TensorArray count: inCount
>     outputs: outTF_OutputArray values: outTF_TensorArrayPtr count: outCount
>     targets: aTF_OperationArray count: targetCount
>     metadata: metaTF_Buffer
>     status: aTF_Status
>     
>     "F_CAPI_EXPORT extern void TF_SessionRun(
>     TF_Session* session,
>     // RunOptions
>     const TF_Buffer* run_options,
>     // Input tensors
>     const TF_Output* inputs, TF_Tensor* const* input_values, int ninputs,
>     // Output tensors
>     const TF_Output* outputs, TF_Tensor** output_values, int noutputs,
>     // Target operations
>     const TF_Operation* const* target_opers, int ntargets,
>     // RunMetadata
>     TF_Buffer* run_metadata,
>     // Output status
>      TF_Status*);"
>         
>         ^ self
>         ffiCall: #(void TF_SessionRun #(TF_Session * aTF_Session, TF_Buffer * 
> opsTF_Buffer, TF_Output * inTF_OutputArray, TF_Tensor * inTF_TensorArray, int 
> inCount, TF_Output * outTF_OutputArray, TF_Tensor * outTF_TensorArrayPtr, int 
> outCount, TF_Operation * aTF_OperationArray, int targetCount, TF_Buffer * 
> metaTF_Buffer, TF_Status * aTF_Status))
>         module: TensorFlowCAPI
> 
> TF_Tensor is an opaque object.
> 
> I have an error: "Could not coerce arguments".
> I guess this is related to the way I pass arguments to the FFI function ?
> 
> -- 
> Serge Stinckwich
> UMI UMMISCO 209 (SU/IRD/UY1)
> "Programs must be written for people to read, and only incidentally for 
> machines to execute."
> http://www.doesnotunderstand.org/ <http://www.doesnotunderstand.org/>

Reply via email to