@theano.gof.local_optimizer([DiagonalSubtensor, IncDiagonalSubtensor])
def local_inplace_DiagonalSubtensor(node):
 if (isinstance(node.op, (DiagonalSubtensor, IncDiagonalSubtensor)) and (not node.op.inplace)):
  new_op = node.op.__class__(inplace=True)
  new_node = new_op(*node.inputs)
  copy_stack_trace(node.outputs[0], new_node)
  return [new_node]
 return False

@ theano . gof . local_optimizer ( [ DiagonalSubtensor , IncDiagonalSubtensor ] ) def local_inplace_DiagonalSubtensor ( node ) : if ( isinstance ( node . op , ( DiagonalSubtensor , IncDiagonalSubtensor ) ) and ( not node . op . inplace ) ) : new_op = node . op . __class__ ( inplace = True ) new_node = new_op ( * node . inputs ) copy_stack_trace ( node . outputs [ 0 ] , new_node ) return [ new_node ] return False
also work for incdiagonalsubtensor .