Unknown builtin op: aten::Tensor

username: dalalaa
cooked: <p>I got this error while trying to convert nn.module to torchscript.</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "/home/dai/scripts/mobileocr/detector/mobilenet_east_deploy.py", line 240, in &lt;module&gt;
    script_module = torch.jit.script(net)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1203, in script
    return torch.jit.torch.jit._recursive.recursive_script(obj)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 173, in recursive_script
    return copy_to_script_module(mod, overload_stubs + stubs)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 95, in copy_to_script_module
    torch.jit._create_methods_from_stubs(script_module, stubs)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1423, in _create_methods_from_stubs
    self._c._create_methods(self, defs, rcbs, defaults)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 222, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1226, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 222, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1226, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
RuntimeError: 
Unknown builtin op: aten::Tensor.
Here are some suggestions: 
	aten::tensor

The original call is:
at /home/dai/scripts/mobileocr/detector/mobilenet_east_deploy.py:193:17
    for i in range(valid_pos.shape[0]):
        x = valid_pos[i,0]
        y = valid_pos[i,1]
        y_min = y - d[0,i]
        y_max = y + d[1,i]
        x_min = x - d[2,i]
        x_max = x + d[3,i]
        rotate_mat = get_rotate_mat_torch(-angle[i])

        temp_x = torch.Tensor([[x_min,x_max,x_max,x_min]]) - x
                 ~~~~~~~~~~~~ &lt;--- HERE
        temp_y = torch.Tensor([[y_min,y_min,y_max,y_max]]) - y
        coordinates = torch.cat([temp_x,temp_y],dim = 0)
        # res = torch.dot(rotate_mat,coordinates)
        res = torch.matmul(rotate_mat,coordinates)
        res[0,:] += x
        res[1,:] += y

        if is_valid_poly_torch(res,score_shape,scale):
            index.append(i)

</code></pre>
<p>My pytorch version is 1.3.1 + cu92</p>
<p>How can I solve this problem or what function can be used to replace torch.Tensor()?</p>
<p>Please remind me if more information is needed.</p>

username: ptrblck
cooked: <p>Try to use the suggested <code>torch.tensor</code> instead (lowercase t).<br>
I would generally not recommend to use <code>torch.Tensor</code>, as this might give you uninitialized code, e.g. by calling <code>torch.Tensor(10)</code>.<br>
<code>torch.tensor</code> is the factory method to pass values as a list etc.</p>

username: dalalaa
cooked: <p>Thank you very much, problem solved.</p>