mindspore/tests/st/ops/ascend/test_host.py

27 lines
702 B
Python
Raw Normal View History

2021-12-03 09:42:30 +08:00
import numpy as np
import mindspore.context as context
import mindspore.nn as nn
from mindspore import Tensor
from mindspore.ops import operations as P
context.set_context(enable_graph_kernel=False, save_graphs=False, mode=context.PYNATIVE_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
2022-03-02 18:51:49 +08:00
self.host = P.TensorShape()
2021-12-03 09:42:30 +08:00
self.t1 = Tensor(np.random.randn(16).astype(np.int32))
def construct(self):
return self.host(self.t1)
def test_net():
"""
Feature: test host kernel in pynative mode
Description: get shape
Expectation: success
"""
net = Net()
out1 = net()
print(out1.asnumpy())