use crate::AnyTensor;
use crate::Operation;
use crate::Result;
use crate::Scope;
use crate::Tensor;
use crate::TensorType;
use tensorflow_internal_macros::define_op;
pub fn constant<T: TensorType, TT: Into<Tensor<T>>>(
value: TT,
scope: &mut Scope,
) -> Result<Operation> {
let name = scope.get_unique_name_for_op("Const");
let mut graph = scope.graph_mut();
let mut c = graph.new_operation("Const", &name)?;
c.set_attr_tensor("value", value.into())?;
c.set_attr_type("dtype", T::data_type())?;
c.finish()
}
pub(crate) fn any_constant(value: &dyn AnyTensor, scope: &mut Scope) -> Result<Operation> {
let name = scope.get_unique_name_for_op("Const");
let mut graph = scope.graph_mut();
let mut c = graph.new_operation("Const", &name)?;
c.set_attr_any_tensor("value", value)?;
c.set_attr_type("dtype", value.data_type())?;
c.finish()
}
#[deprecated(note = "Use mul instead.", since = "0.15.0")]
define_op!(multiply, Multiply, "Mul", args { a, b });
#[deprecated(note = "Use sub instead.", since = "0.15.0")]
define_op!(subtract, Subtract, "Sub", args { a, b });