SubOp class

Subtracts a scalar or tensor from the input element-wise.

Equivalent to torch.sub() in PyTorch.

final result = SubOp(scalar: 1.0)(tensor);  // tensor - 1.0
final result = SubOp.tensor(other)(tensor); // tensor - other
Inheritance

Constructors

SubOp({required double scalar})
Creates a subtraction operation with a scalar operand.
SubOp.tensor(TensorBuffer other)
Creates a subtraction operation with a tensor operand.

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
The human-readable name of this operation.
no setteroverride
other TensorBuffer?
Tensor operand (if using tensor mode).
finalinherited
requiresContiguous bool
Whether this operation requires contiguous input.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scalar double?
Scalar operand (if using scalar mode).
finalinherited

Methods

apply(TensorBuffer input) TensorBuffer
Applies this transform to input and returns the result.
inherited
applyInPlace(TensorBuffer input) → void
Applies this transform to input in place.
inherited
call(TensorBuffer input) TensorBuffer
Alias for apply.
inherited
cloneForModification(TensorBuffer input) TensorBuffer
Creates an output buffer from input, ensuring contiguity with single copy.
inherited
computeOutputShape(List<int> inputShape) List<int>
Computes the output shape for a given inputShape.
inherited
ensureContiguous(TensorBuffer input) TensorBuffer
Returns a contiguous version of input if needed.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
operation(double a, double b) double
The operation to apply element-wise.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited