def infer(self, cond_input, implementation): # cond_input is channels x batch x num_layers x samples assert(cond_input.size()[0:3:2] == (2*self.R, self.num_layers)), \ """Inputs are channels x batch x num_layers x samples. Channels and num_layers should be sizes: {} But input is: {}""".format((2*self.R, self.num_layers), cond_input.size()[0:3:2]) batch_size = cond_input.size(1) sample_count = cond_input.size(3) cond_input = column_major(cond_input) samples = torch.cuda.IntTensor(batch_size, sample_count) nv_wavenet_ext.infer(samples, sample_count, batch_size, self.embedding_prev, self.embedding_curr, self.conv_out, self.conv_end, cond_input, self.num_layers, self.use_embed_tanh, self.max_dilation, implementation, *self.layers) return samples
def infer(self, cond_input, implementation): # cond_input is channels x batch x num_layers x samples try: import nv_wavenet_ext except ImportError as e: raise ImportError( f"{str(e)}. Probably you haven't compiled nv_wavenet. " f"nv_wavenet can be compiled as follows:\n\n" f"cd {Path(__file__).parent}\n" f"make\n" f"python build.py install\n" ) assert(cond_input.size()[0:3:2] == (2*self.R, self.num_layers)), \ """Inputs are channels x batch x num_layers x samples. Channels and num_layers should be sizes: {} But input is: {}""".format( (2*self.R, self.num_layers), cond_input.size()[0:3:2]) batch_size = cond_input.size(1) sample_count = cond_input.size(3) cond_input = column_major(cond_input) samples = torch.cuda.IntTensor(batch_size, sample_count) nv_wavenet_ext.infer( samples, sample_count, batch_size, self.embedding_prev, self.embedding_curr, self.conv_out, self.conv_end, cond_input, self.num_layers, self.use_embed_tanh, self.max_dilation, implementation, self.layers ) return samples