oneflow.typing¶
Typing system¶
-
class
oneflow.typing.
Bundle
¶ One or a collection of typing.Numpy/typing.ListNumpy/typing.ListListNumpy, such as x, [x], (x,), {“key”: x} and the mixed form of them.
-
class
oneflow.typing.
Callback
¶
-
class
oneflow.typing.
ListListNumpy
¶ ListListNumpy is a type hint for numpy output of a OneFlow global function For instance:
@oneflow.global_function() def foo() -> oneflow.typing.ListListNumpy: mirrored_tensor_lists = ... # your network return mirrored_tensor_lists mirrored_tensor_lists = foo() # get a list of list of numpy.ndarray for tensor_list in mirrored_tensor_lists: for tensor in tensor_list: print(mirrored_tensors)
-
Placeholder
(dtype=<class 'oneflow.python.framework.dtype.float32'>, batch_axis: Optional[int] = 0)¶ ListListNumpy.Placeholder is a typing function for numpy input of a OneFlow global function. A list of list of numpy.ndarray takes a ListListNumpy.Placeholder’s place. Each numpy.ndarray in the list could have any shape as long as it has the same rank and a smaller/equal size. For instance:
@oneflow.global_function() def foo( image_blob: oneflow.typing.ListListNumpy.Placeholder( (2, 255, 255, 3), dtype=flow.float32 ) ): # your network input1 = np.random.randn(2, 255, 255, 3).astype(np.float32) input2 = np.random.randn(2, 251, 251, 3).astype(np.float32) foo([[input1]]) foo([[input2]])
-
-
class
oneflow.typing.
ListNumpy
¶ ListNumpy is a type hint for numpy output of a OneFlow global function For instance:
@oneflow.global_function() def foo() -> oneflow.typing.ListNumpy: mirrored_tensors = ... # your network return mirrored_tensors mirrored_tensors = foo() # get a list of numpy.ndarray for tensor in mirrored_tensors: print(mirrored_tensors)
-
Placeholder
(dtype=<class 'oneflow.python.framework.dtype.float32'>, batch_axis: Optional[int] = 0)¶ ListNumpy.Placeholder is a typing function for numpy input of a OneFlow global function. A list of numpy.ndarray takes a ListNumpy.Placeholder’s place. Each numpy.ndarray in the list could have any shape as long as it has the same rank and a smaller/equal size. For instance:
@oneflow.global_function() def foo( image_blob: oneflow.typing.ListNumpy.Placeholder( (2, 255, 255, 3), dtype=flow.float32 ) ): # your network input1 = np.random.randn(2, 255, 255, 3).astype(np.float32) input2 = np.random.randn(2, 251, 251, 3).astype(np.float32) foo([input1]) foo([input2])
-
-
class
oneflow.typing.
Numpy
¶ Numpy is a type hint for numpy output of a OneFlow global function For instance:
@oneflow.global_function() def foo() -> oneflow.typing.Numpy: loss = ... # your network return loss loss = foo() # get a numpy.ndarray print(loss)
-
Placeholder
(dtype=<class 'oneflow.python.framework.dtype.float32'>, batch_axis: Optional[int] = 0)¶ Numpy.Placeholder is a typing function for numpy input of a OneFlow global function. A numpy.ndarray takes a Numpy.Placeholder’s place must have a identical shape. For instance:
@oneflow.global_function() def foo( image_blob: oneflow.typing.Numpy.Placeholder( (2, 255, 255, 3), dtype=flow.float32 ) ): # your network foo(np.random.randn(2, 255, 255, 3).astype(np.float32))
-