TF代码研读-Tensor(TensorShapeRep,TensorShapeBase,TensorShape,PartialTensorShape)

10 篇文章 10 订阅 ¥29.90 ¥99.00
本文详细介绍了TensorFlow中TensorShape类的设计,包括其内部结构、维度存储方式以及与TensorShapeBase和TensorShapeRep的关系。TensorShapeRep使用16字节存储信息,提供不同维度存储格式,并通过TensorShapeBase增加操作接口和迭代器。TensorShape类在基础上实现主要功能,而PartialTensorShape用于处理不确定维度的形状,常在神经网络层间操作中使用。
摘要由CSDN通过智能技术生成

在Tensor类中核心为 TensorShape shape_与TensorBuffer* buf_两个变量.

其中TensorShape类继承与TensorShapeBase<TensorShape> 这个是一个模板类,而TensorShapeBase类继承与TensorShapeRep类.TensorShapeRep是TensorShape的爷爷,TensorShapeBase是TensorShape的爸爸.....

其中爷爷类TensorShapeRep(tensor_shape.h),定义如下:

 

class TensorShapeRep {
 public:
  ~TensorShapeRep();

  //拷贝构造、赋值构造、右值引用、移动构造
  TensorShapeRep(const TensorShapeRep& b);
  void operator=(const TensorShapeRep& b);
  TensorShapeRep(TensorShapeRep&& b);
  void operator=(TensorShapeRep&& b);

  /// Clear a tensor shape, producing the scalar shape.
  void Clear();
  static constexpr int MaxDimensions() { return 254; }//最大维度为254维,255表示未知维度
  int64 num_elements() const { return 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

橘子都吃不起!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值