31 #if !defined(COMPILER_MSVC)
32 #define COMPILER_MSVC // Set MSVC visibility of exported symbols in the shared library.
35 #pragma warning(disable : 4190)
38 #include <tensorflow/c/c_api.h>
46 TF_Graph*
LoadGraph(
const char* graphPath);
55 const TF_Output* inputs,
56 TF_Tensor*
const* input_tensors,
58 const TF_Output* outputs,
59 TF_Tensor** output_tensors,
60 std::size_t noutputs);
63 const std::vector<TF_Output>& inputs,
64 const std::vector<TF_Tensor*>& input_tensors,
65 const std::vector<TF_Output>& outputs,
66 std::vector<TF_Tensor*>& output_tensors);
69 const std::int64_t* dims,
75 TF_Tensor*
CreateTensor(TF_DataType data_type,
const std::vector<std::int64_t>& dims,
const std::vector<T>& data)
81 data.size() *
sizeof(
T));
84 TF_Tensor*
CreateEmptyTensor(TF_DataType data_type,
const std::int64_t* dims, std::size_t num_dims);
86 TF_Tensor*
CreateEmptyTensor(TF_DataType data_type,
const std::vector<std::int64_t>& dims);
92 void SetTensorsData(TF_Tensor* tensor,
const void* data, std::size_t len);
103 auto data =
static_cast<T*
>(TF_TensorData(tensor));
109 return {data, data + (TF_TensorByteSize(tensor) / TF_DataTypeSize(TF_TensorType(tensor)))};
113 std::vector<std::vector<T>>
GetTensorsData(
const std::vector<TF_Tensor*>& tensors)
115 std::vector<std::vector<T>> data;
116 data.reserve(tensors.size());
117 for (
const auto t : tensors)
119 data.push_back(GetTensorsData<T>(t));
127 #if defined(_MSC_VER)