Torch.jit data.new and variable

Hi! I’m trying to script_method the function below and jit complains “attribute lookup is not defined on builtin” for memory.data.new. I tried other variations: 1) torch.zeros, 2) torch.cuda.FloatTensor(shape).zero_() and nothing seems to work.

Any suggestion is welcome. The full model code can be found here:

    def get_go_frame(self, memory):
        decoder_input = Variable(memory.data.new(
            memory.size(0), self.n_mel_channels * self.n_frames_per_step).zero_())
        return decoder_input

This problem has been solved!

You should use memory.new_zeros, btw :slight_smile:

memory.new_zeros actually does not work with a jitted function (script_method)

unknown builtin op:
def get_go_frame(self, memory):
    decoder_input: all zeros frames
    """
    decoder_input = memory.new_zeros(
                    ~~~~~~~~~~ <--- HERE

Any thoughts how to fix it?

I’d probably use torch.zeros and pass device, dtype.

Best regards

Thomas