1

I try to add a new helper function using brew, as shown below.

brew.Register(testOp)

When i try to run above code, i get below error:

AttributeError: Helper testOp already exists. Please change your helper name.

Please help me resolve this error.

NOTE: testOp is defined in same file.

LuFFy
  • 8,799
  • 10
  • 41
  • 59
Anshuman.T
  • 11
  • 2

1 Answers1

0

First, we have to define the function (Our example function only calls the Abs operator):

def absolute_value(model, blob_in, blob_out, **kwargs):
    model.Abs(blob_in, blob_out)

Then, we can register the new helper function:

brew.Register(absolute_value)

Finally, we will test it:

model = ModelHelper(name="test")

x = np.array([[-1, 2, 3], [1, -2, 3], [1, 2, -3]])
workspace.FeedBlob('x', x.astype(np.float32))

brew.absolute_value(model, 'x', 'out')

workspace.RunNetOnce(model.net)

blob = workspace.FetchBlob('out')
print(blob)

The output should be:

[[1. 2. 3.]
 [1. 2. 3.]
 [1. 2. 3.]]
Dani Cores
  • 181
  • 1
  • 6