Eager execution API bug fix for tensor data types whose TF_Tensor memory layout is not the same at the tensorflow::Tensor memory layout.

This commit is contained in:
Anthony Platanios 2017-08-27 00:10:21 -04:00 committed by Martin Wicke
parent 512d3d0868
commit 5598a3dec7
2 changed files with 6 additions and 3 deletions

View File

@ -146,6 +146,8 @@ class TensorCApi {
} }
}; };
Status TF_TensorToTensor(const TF_Tensor* src, Tensor* dst);
TF_Tensor* TF_TensorFromTensor(const Tensor& src, TF_Status* status); TF_Tensor* TF_TensorFromTensor(const Tensor& src, TF_Status* status);
Status MessageToBuffer(const tensorflow::protobuf::Message& in, TF_Buffer* out); Status MessageToBuffer(const tensorflow::protobuf::Message& in, TF_Buffer* out);

View File

@ -152,9 +152,10 @@ TF_DeviceList* TFE_ContextListDevices(TFE_Context* ctx, TF_Status* status) {
} }
TFE_TensorHandle* TFE_NewTensorHandle(TF_Tensor* t) { TFE_TensorHandle* TFE_NewTensorHandle(TF_Tensor* t) {
return new TFE_TensorHandle( tensorflow::Tensor tensor;
tensorflow::TensorCApi::MakeTensor(t->dtype, t->shape, t->buffer), // TODO: Add status argument and check on it.
nullptr); tensorflow::TF_TensorToTensor(t, &tensor);
return new TFE_TensorHandle(tensor, nullptr);
} }
void TFE_DeleteTensorHandle(TFE_TensorHandle* h) { delete h; } void TFE_DeleteTensorHandle(TFE_TensorHandle* h) { delete h; }