-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsupported Ops in the model before optimization TensorScatterUpdate #4222
Comments
cc @annxingyuan |
Hope this implemented soon as well! |
@PeterL1n Since this Op is very similar to ScatterNd op, we should be able to add the support fairly soon. |
Thank you so much! I'm waiting for it! |
Any updates on this thread? |
Is there a way to know what Pytorch operation is converted into |
Hope this is implemented! |
Hope it gets implemented! |
TensorScatterUpdate from the tensorflow docs:
A way to re-write TensorScatterUpdate in terms of ScatterNd could be something like: def TensorScatterUpdate( tensor, indices, updates ):
# zero the indices we want to update
return tensor * ScatterNd(indices, ZerosLike(updates), tensor.shape)
# then add in the updates
+ ScatterNd(indices, updates, tensor.shape) But before TFJS officially supports that, you could export your model with Doing this freehand, untested, but.. registering your custom op in javascript might be like: const customTensorScatterUpdate = function(node){
const tensor = node.inputs[0];
const indices = node.inputs[1];
const updates = node.inputs[2]
const zeros = tf.zerosLike(updates)
return tensor * tf.scatterND(indices, zeros, tensor.shape) + tf.scatterND(indices, updates, tensor.shape)
}
tf.registerOp('TensorScatterUpdate', customTensorScatterUpdate); suspect this implementation would be slower, as it calls scatterND twice. I imagine a faster implementation would just edit the tensor's memory without making copies. |
For those having problems with this code here's the fix! I actually tested it and it works. const customTensorScatterUpdate = function(node){
const tensor = node.inputs[0];
const indices = node.inputs[1];
const updates = node.inputs[2]
const zeros = tf.zerosLike(updates)
const a = tf.mul(tensor, tf.scatterND(indices, zeros, tensor.shape));
const b = tf.scatterND(indices, updates, tensor.shape);
return a.add(b)
}
tf.registerOp('TensorScatterUpdate', customTensorScatterUpdate); |
Hi, @waittim Apologize for the delayed response and I see this PR #7189 got merged so it seems like this issue has been taken care by that PR and also we have updated official documentation for tf.tensorScatterUpdate so Could you please confirm if this issue is resolved for you ? Please feel free to close the issue if it is resolved ? Thank you! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you. |
Closing as stale. Please @mention us if this needs more attention. |
System information
Describe the feature and the current behavior/state.
TensorScatterUpdate
is not supported.Any Other info.
The SavedModel is converted from the onnx model(opset_version=11). You can find the model I used here. The output node names are 'StatefulPartitionedCall,StatefulPartitionedCall_1,StatefulPartitionedCall_2'. It's a yolo model.
May I know is there any other possible solution besides waiting for the support? Thank you!
The text was updated successfully, but these errors were encountered: