def f(x): nonlocal buf neg = ops.Elemwise(mode="negate") (x, ) = apply(neg, x) buf = x.numpy() (x, ) = apply(neg, x) return x
def f(x): nonlocal buf neg = ops.Elemwise(Elemwise.Mode.NEGATE) (x, ) = apply(neg, x) buf = x.numpy() (x, ) = apply(neg, x) return x
def f(x): neg = ops.Elemwise(Elemwise.Mode.NEGATE) (x, ) = apply(neg, x) with exclude_from_trace(): if i % 2: (x, ) = apply(neg, x) (x, ) = apply(neg, x) return x
def f(x): neg = ops.Elemwise(mode="negate") (x, ) = apply(neg, x) with exclude_from_trace(): if i % 2: (x, ) = apply(neg, x) (x, ) = apply(neg, x) return x
def test_opdef_serialization(): with TemporaryFile() as f: x = builtin.Elemwise(mode="Add") pickle.dump(x, f) f.seek(0) load_x = pickle.load(f) assert x == load_x with TemporaryFile() as f: x = builtin.Convolution(stride_h=9, compute_mode="float32") x.strategy = (builtin.Convolution.Strategy.PROFILE | builtin.Convolution.Strategy.HEURISTIC | builtin.Convolution.Strategy.REPRODUCIBLE) pickle.dump(x, f) f.seek(0) load_x = pickle.load(f) assert x.strategy == load_x.strategy assert x == load_x
def f(a, b): op = ops.Elemwise(Elemwise.Mode.ADD) (y, ) = apply(op, a, b) return y
def f(x): op = ops.Elemwise(Elemwise.Mode.NEGATE) (y, ) = apply(op, x) return y
def f(x): op = ops.Elemwise(Elemwise.Mode.MUL) (y, ) = apply(op, x, p) return y
def f(a, b): op = ops.Elemwise(mode="add") (y, ) = apply(op, a, b) return y
def f(x): op = ops.Elemwise(mode="negate") (y, ) = apply(op, x) return y
def f(x): op = ops.Elemwise(mode="mul") (y, ) = apply(op, x, p) return y
def forward(self, x): out = x.shape out = apply(builtin.Elemwise(mode="ADD"), out, Tensor(1)) return out