Skip to content

Commit fc2f875

Browse files
Ops added: shape and one not encoding
1 parent 0ee3ace commit fc2f875

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ravop/core/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def slice(self, **kwargs):
203203
def find_indices(self, op, **kwargs):
204204
return find_indices(self, op, **kwargs)
205205

206+
def shape_(self, **kwargs):
207+
return shape(self, **kwargs)
208+
206209
# Comparison Ops
207210
def greater(self, op1, **kwargs):
208211
return greater(self, op1, **kwargs)
@@ -326,6 +329,8 @@ def __str__(self):
326329
self._op_db.operator,
327330
self.output,
328331
self.status)
332+
def __call__(self, *args, **kwargs):
333+
return self.output
329334

330335

331336
class Scalar(Op):
@@ -368,6 +373,9 @@ def __str__(self):
368373
return "Scalar Op:\nId:{}\nOutput:{}\nStatus:{}\nDtype:{}\n".format(self.id, self.output,
369374
self.status, self.dtype)
370375

376+
def __call__(self, *args, **kwargs):
377+
return self.output
378+
371379

372380
class Tensor(Op):
373381
"""
@@ -411,6 +419,9 @@ def __str__(self):
411419
return "Tensor Op:\nId:{}\nOutput:{}\nStatus:{}\nDtype:{}\n".format(self.id, self.output,
412420
self.status, self.dtype)
413421

422+
def __call__(self, *args, **kwargs):
423+
return self.output
424+
414425

415426
class Data(object):
416427
def __init__(self, id=None, value=None, dtype=None, **kwargs):
@@ -471,6 +482,9 @@ def dtype(self):
471482
def __str__(self):
472483
return "Data:\nId:{}\nDtype:{}\n".format(self.id, self.dtype)
473484

485+
def __call__(self, *args, **kwargs):
486+
return self.value
487+
474488

475489
class Graph(object):
476490
"""A class to represent a graph object"""
@@ -707,6 +721,10 @@ def find_indices(op, op2, **kwargs):
707721
return __create_math_op(op, op2, Operators.FIND_INDICES.value, **kwargs)
708722

709723

724+
def shape(op, **kwargs):
725+
return __create_math_op2(op, Operators.SHAPE.value, **kwargs)
726+
727+
710728
# Comparison
711729
def greater(op1, op2, **kwargs):
712730
return __create_math_op(op1, op2, Operators.GREATER.value, **kwargs)
@@ -797,6 +815,12 @@ def sign(op1, **kwargs):
797815
def foreach(op, **kwargs):
798816
return __create_math_op2(op, Operators.FOREACH.value, **kwargs)
799817

818+
# Data Preprocessing
819+
820+
821+
def one_hot_encoding(op, **kwargs):
822+
return __create_math_op2(op, Operators.ONE_HOT_ENCODING.value, **kwargs)
823+
800824

801825
def __create_math_op(op1, op2, operator, **kwargs):
802826
if op1 is None or op2 is None:

ravop/enums.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Operators(Enum):
5353
TILE = "tile"
5454
SLICE = "slice"
5555
FIND_INDICES = "find_indices"
56+
SHAPE = "shape"
5657

5758
# Comparison Operators
5859
GREATER = "greater"
@@ -83,6 +84,9 @@ class Operators(Enum):
8384
SIGN = "sign"
8485
FOREACH = "foreach"
8586

87+
# Data Preprocessing
88+
ONE_HOT_ENCODING = "one_hot_encoding"
89+
8690

8791
class TFJSOperators(Enum):
8892
SIGMOID = "sigmoid"

0 commit comments

Comments
 (0)