mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 11:27:06 +08:00
add example functions to default worker (#210)
This commit is contained in:
committed by
Philipp Moritz
parent
eff6924b7c
commit
529e86ce64
@@ -0,0 +1,25 @@
|
||||
import ray
|
||||
import numpy as np
|
||||
from typing import List
|
||||
|
||||
@ray.remote([int], [float])
|
||||
def estimate_pi(n):
|
||||
x = np.random.uniform(size=n)
|
||||
y = np.random.uniform(size=n)
|
||||
return 4 * np.mean(x ** 2 + y ** 2 < 1)
|
||||
|
||||
@ray.remote([int], [int])
|
||||
def increment(x):
|
||||
return x + 1
|
||||
|
||||
@ray.remote([List[int]], [np.ndarray])
|
||||
def zeros(shape):
|
||||
return np.zeros(shape)
|
||||
|
||||
@ray.remote([np.ndarray, np.ndarray], [np.ndarray])
|
||||
def dot(a, b):
|
||||
return np.dot(a, b)
|
||||
|
||||
@ray.remote([], [])
|
||||
def throw_exception():
|
||||
raise Exception("This function intentionally failed.")
|
||||
Reference in New Issue
Block a user