Hi all, I have used add_matrix_multiply() and in that kNONE is provided but it is not accepting. Let me know how and what value I should provide for kNONE

C = network.add_matrix_multiply(A, kNONE, B, kNONE)

NameError: name ‘kNONE’ is not defined

Hi,

You can find some examples in our document below:

https://docs.nvidia.com/deeplearning/tensorrt/operators/docs/MatrixMultiply.html

For example:

```
layer = network.add_matrix_multiply(in1, trt.MatrixOperation.NONE, in2, trt.MatrixOperation.NONE)
```

Thanks.

Hi, thank you for your suggestion. I tried it but still got the error as

File “build_sample_engine.py”, line 42, in main

C = network.add_matrix_multiply(A, trt.MatrixOperation.NONE, B, trt.MatrixOperation.NONE)

TypeError: add_matrix_multiply(): incompatible function arguments. The following argument types are supported:

1. (self: tensorrt.tensorrt.INetworkDefinition, input0: tensorrt.tensorrt.ITensor, op0: tensorrt.tensorrt.MatrixOperation, input1: tensorrt.tensorrt.ITensor, op1: tensorrt.tensorrt.MatrixOperation) → tensorrt.tensorrt.IMatrixMultiplyLayer

Invoked with: <tensorrt.tensorrt.INetworkDefinition object at 0x7f896458b8>, array([[1., 2.],

[3., 4.]], dtype=float32), <MatrixOperation.NONE: 0>, array([[5., 6.],

[7., 8.]], dtype=float32), <MatrixOperation.NONE: 0>

Hi, I have fixed this by copying the sample code from the link you have shared.

The reason for the problem was not the op0 and op1 but input0: tensorrt.tensorrt.ITensor and input1:tensorrt.tensorrt.ITensor

Earlier the A and B which I had provided for these two parameters were only a 2-D tensor created using np.array()

A = np.array([[1, 2], [3,4]], dtype=np.float32)

B = np.array([[5, 6], [7,8]], dtype=np.float32)

but actually they must be the return values from the

in1 = network.add_input(“input1”, dtype=trt.float32, shape=input_shape)

in2 = network.add_input(“input2”, dtype=trt.float32, shape=input_shape2)

They should be in1 and in2 as below

layer = network.add_matrix_multiply(in1, trt.MatrixOperation.NONE, in2, trt.MatrixOperation.NONE)

and it worked.

Thank you for sharing the link to get actual code to make it work.

Thanks and Regards

Nagaraj Trivedi

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.