我想在tensorflow中添加一个新的整数Matrix Multiplication OP,并且我无法将其成功注册为tf操作,以便它可以成为在python中称为tf.intmatmul。无法在Tensorflow中的Python shell中获得新的tf.Operation
我做的步骤: 1)在math_ops.cc文件中新增了一个REGISTER_OP - IntMatMul。
2)增加了对这种OP在芯/内核路径中的新内核执行 - int_matmul_op.cc和一个相应的头文件 - int_matmul_op.h
3)I添加OP的依赖性在芯/内核/ BUILD文件。这将为此OP添加内核链接。
4)添加了定义该OP(如 'intmatmul')在Python包装文件即蟒/操作/ math_ops.py - 此文件调用gen_math_ops.int_mat_mul
从源5)重新建使用Bazel并使用pip软件包重新安装Tensorflow。
但是,当我尝试将此OP用作tf.intmatmul时,出现错误,提示模块未定义。 我不知道现在我在这里错过了什么。有什么链接丢失? 我是否还需要在核心/ BUILD文件中添加任何OP链接?
我也试了一下。不起作用。我相信tensorflow采用在python包装中定义的名称。在这种情况下,我已经将它定义为intmatmul在python包装中。 –
我应该在哪里做这个别名?在python包装文件? –
我尝试了这两种方法。似乎还没有为我工作呢。确切的错误是: AttributeError的回溯(最近最后调用)在() 1 MAT1 = tf.placeholder(tf.int16) 2 MAT2 = tf.placeholder(TF。 int16) ----> 3 pro = tf。intmatmul(mat1,mat2) AttributeError:'模块'对象没有属性'intmatmul' –