31 #ifndef INCLUDE_CPPFLOW_OPS_H_
32 #define INCLUDE_CPPFLOW_OPS_H_
38 #include "cppflow/raw_ops.h"
51 tensor
operator+(
const tensor& x,
const tensor& y);
56 tensor
operator-(
const tensor& x,
const tensor& y);
61 tensor
operator*(
const tensor& x,
const tensor& y);
66 tensor
operator/(
const tensor& x,
const tensor& y);
96 inline std::ostream& operator<<(std::ostream& os,
const cppflow::tensor& t) {
97 std::string res = to_string(t);
102 auto res_tensor = string_format({t.
shape(), t},
"(tensor: shape=%s, dtype=" +
to_string(t.
dtype()) +
", data=\n%s)");
103 auto res_tensor_h = res_tensor.get_tensor();
105 #ifdef TENSORFLOW_C_TF_TSTRING_H_
109 auto* t_str = (TF_TString*)(TF_TensorData(res_tensor_h.get()));
110 auto result = std::string(TF_TString_GetDataPointer(t_str), TF_TString_GetSize(t_str));
112 const char* dst[1] = {
nullptr};
113 size_t dst_len[1] = {3};
114 TF_StringDecode(
static_cast<char*
>(TF_TensorData(res_tensor_h.get())) + 8, TF_TensorByteSize(res_tensor_h.get()), dst,
115 dst_len, context::get_status());
116 status_check(context::get_status());
117 auto result = std::string(dst[0], *dst_len);
A TensorFlow eager tensor wrapper.
Definition: tensor.h:61
tensor shape() const
Definition: tensor.h:226
datatype dtype() const
Definition: tensor.h:282
std::ostream & operator<<(std::ostream &os, datatype dt)
Definition: datatype.h:127
std::string to_string(datatype dt)
Definition: datatype.h:48
tensor operator*(const tensor &x, const tensor &y)
Definition: ops.h:92
tensor operator+(const tensor &x, const tensor &y)
Definition: ops.h:88
tensor operator-(const tensor &x, const tensor &y)
Definition: ops.h:90
tensor operator/(const tensor &x, const tensor &y)
Definition: ops.h:94