Exemplo n.º 1
0
 def forward(self, x):
     if x.dtype == self.dtype: return x
     if not self.inplace:
         inputs = [x]
         self.unify_devices(inputs)
         outputs = [self.register_output()]
         y = self.run(inputs, outputs)
     else:
         self.unify_devices([x])
         with no_grad():
             y = self.run([], [x])
     return y
Exemplo n.º 2
0
 def forward(self, x, y):
     inputs = [x]
     self.unify_devices(inputs)
     outputs = [y] if y else [self.register_output()]
     with no_grad():
         return self.run(inputs, outputs)