oneflow.typing¶
Typing system¶
-
class
oneflow.typing.
Bundle
¶ One or a collection of typing.Numpy/typing.ListNumpy, such as x, [x], (x,), {“key”: x} and the mixed form of them.
-
class
oneflow.typing.
Callback
¶
-
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=oneflow.float32)¶ 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=oneflow.float32)¶ 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 an 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))
-