MCPcopy Create free account
hub / github.com/cactus-compute/cactus / Tensor

Class Tensor

python/src/graph.py:292–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290
291
292class Tensor:
293 def __init__(self, g, node_id, shape, dtype):
294 self.g = g
295 self.id = int(node_id)
296 self.shape = tuple(shape)
297 self.dtype = int(dtype)
298
299 def __add__(self, other):
300 return self.g.add(self, other)
301
302 def __sub__(self, other):
303 return self.g.subtract(self, other)
304
305 def __mul__(self, other):
306 return self.g.multiply(self, other)
307
308 def __truediv__(self, other):
309 return self.g.divide(self, other)
310
311 def abs(self):
312 return self.g.abs(self)
313
314 def pow(self, exponent):
315 return self.g.pow(self, exponent)
316
317 def relu(self):
318 return self.g.relu(self)
319
320 def sigmoid(self):
321 return self.g.sigmoid(self)
322
323 def tanh(self):
324 return self.g.tanh(self)
325
326 def gelu(self):
327 return self.g.gelu(self)
328
329 def view(self, shape):
330 return self.g.view(self, shape)
331
332 def flatten(self, start_dim=0, end_dim=-1):
333 return self.g.flatten(self, start_dim=start_dim, end_dim=end_dim)
334
335 def concat(self, other, axis=0):
336 return self.g.concat(self, other, axis=axis)
337
338 def cat(self, tensors, axis=0):
339 return self.g.cat([self] + tensors, axis=axis)
340
341 def group_norm(self, normalized_shape, eps=1e-5):
342 return self.g.group_norm(self, normalized_shape, eps)
343
344 def layer_norm(self, normalized_shape, eps=1e-5):
345 return self.g.layer_norm(self, normalized_shape, eps)
346
347 def softmax(self, axis=-1):
348 return self.g.softmax(self, axis)
349

Callers 2

_rebind_tensorMethod · 0.90
_tensor_from_nodeMethod · 0.85

Calls

no outgoing calls

Tested by 1

_rebind_tensorMethod · 0.72