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()
}
define_op!(multiply, Multiply, "Mul", "Use mul instead.", args { a, b });
define_op!(subtract, Subtract, "Sub", "Use sub instead.", args { a, b });