Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 我想用lldb打印张量值_C++_Tensorflow_Lldb - Fatal编程技术网

C++ 我想用lldb打印张量值

C++ 我想用lldb打印张量值,c++,tensorflow,lldb,C++,Tensorflow,Lldb,我想用buf_3;打印缓冲区成员变量,换句话说, 我想p*(tensorflow::Buffer*)buf打印类缓冲区中的成员变量 tensorflow中的代码,1.10.1 类关系:类TensorBuffer是tensor.h中的基类,Buffer是tensor.cc中的模板和派生类 以下是lldb的输出: frame #0: 0x0000000175abffc0 libtensorflow_framework.so`tensorflow::Tensor::Tensor(this=0x00

我想用buf_3;打印缓冲区成员变量,换句话说, 我想
p*(tensorflow::Buffer*)buf
打印类缓冲区中的成员变量

tensorflow中的代码,1.10.1

类关系:类TensorBuffer是tensor.h中的基类,Buffer是tensor.cc中的模板和派生类

以下是lldb的输出:

frame #0: 0x0000000175abffc0 
libtensorflow_framework.so`tensorflow::Tensor::Tensor(this=0x000070000cadd308,a=0x00007fd91ea61500,type=DT_STRING,shape=0x0000700CADD2F0)位于Tensor.cc:726:3

     723  CHECK_NOTNULL(a);

     724  if (shape_.num_elements() > 0 || a->ShouldAllocateEmptyTensors()) {

     725    CASES(type, buf_ = new Buffer<T>(a, shape.num_elements()));

->   726  }


(lldb) p buf_

(tensorflow::TensorBuffer *) $17 = 0x00007fd91e927c40

(lldb) p *(Buffer<std::__1::string>*)buf_

error: use of undeclared identifier 'Buffer'

error: expected '(' for function-style cast or type construction

error: expected expression

(lldb) p *(tensorflow::Buffer<std::__1::string>*)buf_

error: no member named 'Buffer' in namespace 'tensorflow'

error: expected '(' for function-style cast or type construction

error: expected expression
723 CHECK\u NOTNULL(a);
724 if(shape|.num|elements()>0|a->shouldAllocateEmptySensors()){
725例(type,buf_=新缓冲区(a,shape.num_elements());
->   726  }
(lldb)p buf_
(tensorflow::TensorBuffer*)$17=0x00007fd91e927c40
(lldb)p*(Buffer*)buf_
错误:使用未声明的标识符“缓冲区”
错误:函数样式转换或类型构造应为“(”
错误:应为表达式
(lldb)p*(tensorflow::Buffer*)buf_
错误:命名空间“tensorflow”中没有名为“Buffer”的成员
错误:函数样式转换或类型构造应为“(”
错误:应为表达式
第725行解码:

switch(type)

case DataTypeToEnum<string>::value :

{

    typedef string T;

    buf_ = new Buffer<T>(a, shape.num_elements(), allocation_attr);

}
开关(类型)
案例DataTypeToEnum::值:
{
typedef字符串T;
buf=新缓冲区(a,shape.num\u elements(),allocation\u attr);
}

是的,这是从调试信息重建模板类型的问题。DWARF调试信息格式没有模板的抽象表示形式。它只记录实例化的模板(即,没有抽象的
std::vector
,只有
std::vector
vector
,等等)

例如,从一堆特定的实例化中构造一个基本的“std::string”类型,这是clang在强制转换时所需要的,而lldb还没有被教会去做这件事,结果证明这是相当棘手的

通过为要打印的类型引入typedef,您可以临时解决此问题,例如:

(lldb) source list -l 1
   1    #include <vector>
   2    #include <string>
   3    #include <stdio.h>
   4    
   5    int
   6    main()
   7    {
   8      using VecType = std::vector<std::string>;
   9      std::vector<std::string> my_vec = {"string", "other string"};
   10     void *hidden = (void *) &my_vec;
(lldb) 
   11     VecType *revealed = (VecType *) hidden;
   12     return 0;
   13   }
   14   
   15     
(lldb) expr *(std::vector<std::string> *) hidden
error: no member named 'vector' in namespace 'std'
error: expected '(' for function-style cast or type construction
error: expected expression
(lldb) expr *(VecType *) hidden
(VecType) $0 = size=2 {
  [0] = "string"
  [1] = "other string"

是的,这是从调试信息重建模板类型的问题。DWARF调试信息格式没有模板的抽象表示形式。它只记录实例化的模板(即没有抽象的
std::vector
,只有
std::vector
vector
,等等)

例如,从一堆特定的实例化中构造一个基本的“std::string”类型,这是clang在强制转换时所需要的,而lldb还没有被教会去做这件事,结果证明这是相当棘手的

通过为要打印的类型引入typedef,您可以临时解决此问题,例如:

(lldb) source list -l 1
   1    #include <vector>
   2    #include <string>
   3    #include <stdio.h>
   4    
   5    int
   6    main()
   7    {
   8      using VecType = std::vector<std::string>;
   9      std::vector<std::string> my_vec = {"string", "other string"};
   10     void *hidden = (void *) &my_vec;
(lldb) 
   11     VecType *revealed = (VecType *) hidden;
   12     return 0;
   13   }
   14   
   15     
(lldb) expr *(std::vector<std::string> *) hidden
error: no member named 'vector' in namespace 'std'
error: expected '(' for function-style cast or type construction
error: expected expression
(lldb) expr *(VecType *) hidden
(VecType) $0 = size=2 {
  [0] = "string"
  [1] = "other string"
我们可以使用张量的data()函数来解决这个问题

例如
p(std::uu 1::string*)(tensor->buf->data())
为什么我们可以在lldb中使用data()函数?

我们可以使用张量的data()函数来解决这个问题

例如
p(std::uu 1::string*)(tensor->buf->data())

为什么我们可以在lldb中使用data()函数?

我重新安装了lldb 9.0.0,但有相同的问题。我重新安装了lldb 9.0.0,但有相同的问题。我尝试使用xxx=Buffer查找
,但没有找到相关的代码。我尝试使用xxx=Buffer查找
,但没有找到相关的代码。