Skip to content

Commit f7ca75c

Browse files
Fix lint "clippy::derivable_impls"
The code is not used anywhere else.
1 parent 4946d5c commit f7ca75c

File tree

2 files changed

+21
-91
lines changed

2 files changed

+21
-91
lines changed

src/eager/op.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ use crate::{AnyTensor, Code, DataType, Result, Shape, Status};
1616

1717
use tensorflow_sys as tf;
1818

19-
#[cfg(test)]
20-
mod op_test_util;
21-
2219
#[allow(
2320
non_snake_case,
2421
clippy::too_many_arguments,
@@ -417,9 +414,8 @@ impl<'a> Op<'a> {
417414
#[cfg(test)]
418415
mod tests {
419416
use super::*;
420-
use crate::eager::{Context, ContextOptions, TensorHandle};
417+
use crate::eager::{Context, ContextOptions, TensorHandle, ToTensorHandle};
421418
use crate::Tensor;
422-
use op_test_util::add as add_ut;
423419
use raw_ops::{add, concat_v2};
424420

425421
#[cfg(feature = "ndarray")]
@@ -482,6 +478,26 @@ mod tests {
482478
let h_y = h_x.copy_sharing_tensor().unwrap();
483479
let expected = Tensor::new(&[2, 2]).with_values(&[2i32, 4, 6, 8]).unwrap();
484480

481+
fn add_ut<'a, T0, T1>(
482+
ctx: &'a crate::eager::Context,
483+
x: &T0,
484+
y: &T1,
485+
) -> Result<TensorHandle<'a>>
486+
where
487+
T0: ToTensorHandle<'a>,
488+
T1: ToTensorHandle<'a>,
489+
{
490+
let op_name = "Add";
491+
let mut op = Op::new(ctx, op_name)?;
492+
493+
// Required input arguments
494+
op.add_input(&x.to_handle(ctx)?)?;
495+
op.add_input(&y.to_handle(ctx)?)?;
496+
497+
let [h] = op.execute::<1>(ctx)?;
498+
Ok(h)
499+
}
500+
485501
// tensor and tensor
486502
let h_z = add_ut(&ctx, &x, &x).unwrap();
487503
let z = h_z.resolve::<i32>().unwrap();

src/eager/op/op_test_util.rs

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +0,0 @@
1-
#![allow(non_snake_case)]
2-
/// Code for Op's ut that mimics raw_opw.
3-
use crate::eager::{TensorHandle, ToTensorHandle};
4-
use crate::Result;
5-
6-
use super::Op;
7-
8-
/// Add
9-
#[derive(::std::fmt::Debug)]
10-
pub struct Add {
11-
T: ::std::option::Option<crate::DataType>,
12-
device_name: ::std::option::Option<String>,
13-
}
14-
15-
impl ::std::default::Default for Add {
16-
fn default() -> Self {
17-
Self {
18-
T: None,
19-
device_name: None,
20-
}
21-
}
22-
}
23-
24-
impl Add {
25-
/// Creates a new `Add`.
26-
pub fn new() -> Self {
27-
Self::default()
28-
}
29-
30-
/// Sets the `T` attribute.
31-
pub fn T<ArgType: ::std::convert::Into<crate::DataType>>(mut self, value: ArgType) -> Self {
32-
self.T = ::std::option::Option::Some(value.into());
33-
self
34-
}
35-
36-
/// Set the `device_name` where in the Op is executed.
37-
pub fn set_device(&mut self, device_name: &str) {
38-
self.device_name = ::std::option::Option::Some(device_name.to_string());
39-
}
40-
41-
/// Execute add.
42-
pub fn call<'a, T0, T1>(
43-
&self,
44-
ctx: &'a crate::eager::Context,
45-
x: &T0,
46-
y: &T1,
47-
) -> Result<TensorHandle<'a>>
48-
where
49-
T0: ToTensorHandle<'a>,
50-
T1: ToTensorHandle<'a>,
51-
{
52-
// Define Op
53-
54-
let op_name = "Add";
55-
let mut op = Op::new(ctx, op_name)?;
56-
57-
// Required input arguments
58-
op.add_input(&x.to_handle(ctx)?)?;
59-
op.add_input(&y.to_handle(ctx)?)?;
60-
61-
// Attributes
62-
if let ::std::option::Option::Some(value) = &self.T {
63-
let attr_name = "T";
64-
op.set_attr_type(attr_name, *value)?;
65-
}
66-
67-
// Device
68-
if let ::std::option::Option::Some(device_name) = &self.device_name {
69-
op.set_device(device_name)?;
70-
}
71-
72-
// Execute Op
73-
let [h] = op.execute::<1>(ctx)?;
74-
Ok(h)
75-
}
76-
}
77-
78-
/// add with default options.
79-
pub fn add<'a, T0, T1>(ctx: &'a crate::eager::Context, x: &T0, y: &T1) -> Result<TensorHandle<'a>>
80-
where
81-
T0: ToTensorHandle<'a>,
82-
T1: ToTensorHandle<'a>,
83-
{
84-
let op = Add::new();
85-
op.call(ctx, x, y)
86-
}

0 commit comments

Comments
 (0)