Caution: The FlatBufferModel object must remain valid until all
instances of Interpreter using it have been destroyed.
This means that the pointer to the memory is retained by the C code.
However, passing a pointer to Go allocated memory directly is forbidden
(https://golang.org/cmd/cgo/#hdr-Passing_pointers):
C code may not keep a copy of a Go pointer after the call returns.
This includes the GoString type, which, as noted above, includes a Go
pointer; GoString values may not be retained by C code.
This code changes NewModel to use C.CBytes which will malloc memory in C
and copy the data.
https://www.tensorflow.org/lite/guide/inference#load_and_run_a_model_in_c
This means that the pointer to the memory is retained by the C code. However, passing a pointer to Go allocated memory directly is forbidden (https://golang.org/cmd/cgo/#hdr-Passing_pointers):
This code changes NewModel to use C.CBytes which will malloc memory in C and copy the data.