代码研读 Tensor类
Tensor类定义在tensorflow/core/framework/tensor.h中
Tensor定义了以下几个构造函数
//默认构造函数.初始化一个1维0元素的float张量
Tensor();
//另外一种构造函数Tensor(DT_FLOAT, TensorShape({}))
Tensor(DataType type, const TensorShape& shape);
//指定内存分配器,构造
Tensor(Allocator* a, DataType type, const TensorShape& shape);
/// 注释上来说直接在op中直接调用Tensor构造函数来创建张量的方式已经弃用了,现在是使用OpKernelConstruction/OpKernelContext allocate_*
// 的方式来创建一个新的张量
/// `a` must outlive the lifetime of this Tensor.
Tensor(Allocator* a, DataType type, const TensorShape& shape,
const AllocationAttributes& allocation_attr);
explicit Tensor(DataType type);
针对标量(单个数字),专门定义了一个空的结构体来标记