예제 #1
0
 def f(x):
     nonlocal buf
     neg = ops.Elemwise(mode="negate")
     (x, ) = apply(neg, x)
     buf = x.numpy()
     (x, ) = apply(neg, x)
     return x
예제 #2
0
 def f(x):
     nonlocal buf
     neg = ops.Elemwise(Elemwise.Mode.NEGATE)
     (x, ) = apply(neg, x)
     buf = x.numpy()
     (x, ) = apply(neg, x)
     return x
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
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
예제 #6
0
 def f(a, b):
     op = ops.Elemwise(Elemwise.Mode.ADD)
     (y, ) = apply(op, a, b)
     return y
예제 #7
0
 def f(x):
     op = ops.Elemwise(Elemwise.Mode.NEGATE)
     (y, ) = apply(op, x)
     return y
예제 #8
0
 def f(x):
     op = ops.Elemwise(Elemwise.Mode.MUL)
     (y, ) = apply(op, x, p)
     return y
예제 #9
0
 def f(a, b):
     op = ops.Elemwise(mode="add")
     (y, ) = apply(op, a, b)
     return y
예제 #10
0
 def f(x):
     op = ops.Elemwise(mode="negate")
     (y, ) = apply(op, x)
     return y
예제 #11
0
 def f(x):
     op = ops.Elemwise(mode="mul")
     (y, ) = apply(op, x, p)
     return y
예제 #12
0
 def forward(self, x):
     out = x.shape
     out = apply(builtin.Elemwise(mode="ADD"), out, Tensor(1))
     return out