Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bugs in oneflow backend implement #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions tensorlayerx/backend/ops/oneflow_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def random_uniform(shape, minval=0, maxval=1, dtype=None, seed=None):
if seed is not None:
flow.manual_seed(seed)
else:
flow.manual_seed(flow.random.gen_seed())
flow.manual_seed(flow.initial_seed())

w = flow.randn(shape, dtype=_dtypeDict[dtype])
out = w.uniform_(minval, maxval)
Expand Down Expand Up @@ -211,7 +211,7 @@ def random_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None):
if seed is not None:
flow.manual_seed(seed)
else:
flow.manual_seed(flow.random.gen_seed())
flow.manual_seed(flow.initial_seed())

return flow.normal(shape, mean=mean, std=stddev, dtype=_dtypeDict[dtype])

Expand Down Expand Up @@ -241,7 +241,7 @@ def truncated_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None):
if seed is not None:
flow.manual_seed(seed)
else:
flow.manual_seed(flow.random.gen_seed())
flow.manual_seed(flow.initial_seed())

w = flow.empty(shape, dtype=_dtypeDict[dtype])
out = nn.init.truncated_normal_(w, mean=mean, std=stddev)
Expand Down Expand Up @@ -271,7 +271,7 @@ def he_normal(shape, dtype=None, seed=None):
if seed is not None:
flow.manual_seed(seed)
else:
flow.manual_seed(flow.random.gen_seed())
flow.manual_seed(flow.initial_seed())

w = flow.empty(shape, dtype=_dtypeDict[dtype])
out = nn.init.kaiming_normal_(w)
Expand Down Expand Up @@ -301,7 +301,7 @@ def he_uniform(shape, dtype=None, seed=None):
if seed is not None:
flow.manual_seed(seed)
else:
flow.manual_seed(flow.random.gen_seed())
flow.manual_seed(flow.initial_seed())

w = flow.empty(shape, dtype=_dtypeDict[dtype])
out = nn.init.kaiming_uniform_(w)
Expand Down Expand Up @@ -331,7 +331,7 @@ def xavier_normal(shape, dtype=None, seed=None):
if seed is not None:
flow.manual_seed(seed)
else:
flow.manual_seed(flow.random.gen_seed())
flow.manual_seed(flow.initial_seed())

w = flow.empty(shape, dtype=_dtypeDict[dtype])
out = nn.init.xavier_normal_(w)
Expand Down Expand Up @@ -363,7 +363,7 @@ def xavier_uniform(shape, gain=1.0, dtype=None, seed=None):
if seed is not None:
flow.manual_seed(seed)
else:
flow.manual_seed(flow.random.gen_seed())
flow.manual_seed(flow.initial_seed())

w = flow.empty(shape, dtype=_dtypeDict[dtype])
out = nn.init.xavier_uniform_(w, gain=gain)
Expand Down Expand Up @@ -674,7 +674,7 @@ def reduce_mean(input_tensor, axis=None, keepdims=False):
if axis is not None:
return flow.mean(input_tensor, dim=axis, keepdim=keepdims)
else:
return flow.mean(input_tensor, keepdim=keepdims)
return flow.mean(input_tensor)


class ReduceMax(object):
Expand Down Expand Up @@ -718,7 +718,7 @@ def reduce_max(input_tensor, axis=None, keepdims=False):
if axis is not None:
return flow.max(input_tensor, dim=axis, keepdim=keepdims)
else:
return flow.max(input_tensor, keepdim=keepdims)
return flow.max(input_tensor)


def reduce_min(input_tensor, axis=None, keepdims=False):
Expand Down Expand Up @@ -1582,11 +1582,11 @@ def count_nonzero(x, axis=None, keepdims=None, dtype="int64"):
return convert_to_tensor(non_zero)


def cumprod(x, axis=None, dtype=None, out=None):
def cumprod(x, axis=0, dtype=None, out=None):
return flow.cumprod(x, dim=axis)


def cumsum(x, axis=None, dtype=None, out=None):
def cumsum(x, axis=0, dtype=None, out=None):
return flow.cumsum(x, dim=axis)

def equal(x, y):
Expand Down Expand Up @@ -1892,7 +1892,7 @@ def mask_select(x, mask, axis = 0):
elif axis == 3:
return x[:,:,:, mask]

def eye(n, m=None, dtype=None):
def eye(n, m=None, dtype=flow.float32):
if m is None:
m = n
return flow.eye(n, m, dtype=dtype)
Expand Down