This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Commit 5d6ffc9
Algebraic operation add( + ), sub( - ), mul( * ), div( / ) for BaseNode class (#439)
* BaseNode / Edge class text input protection added (#423)
BaseNode class - Add protection to name, axis_names
*Protected in 3 place
*Initialize stage - __init__
*Function use setting - set_name / add_axis_names
*Property - Add @Property to name to protect direct adding node.name = 123
Edge class - Add protection to name
*Protected in 3 place
*Initialize stage - __init__
*Function use setting - set_name
*Property
* BaseNode / Edge class text input protection code revise (#423)
*if type(name) != str
*if not isinstance(name, str)
*change using type to isinstance to follow pylint
* Algebraic operation add( + ), sub( - ), mul( * ), div( / ) for BaseNode class (#292)
*[BaseNode class] - add / sub / mul / truediv NotImplemented function Added
*[Node class] - add / sub / mul / truediv function added
*[CopyNode class] - overload the BaseNode mul / truediv as NotImplemented
*[basebackend] - add / sub / mul / div NotImplemented function added
*[numpy / tensorflow / pytorch] - add / sub / mul / div function added
*[shell] - add / sub / div NotImplemented function added
*Testing files
[network_components_free_test]
* Exception - Tensorflow is not tested when the operand is scalar
* 1. Check add / sub / mul / div with int / float / Node
* 2. Check implicit conversion
* 2. Check the Type Error when type is not int / float / Node
* 3. Check is the operand backend same
* 4. Check is BaseNode has attribute _tensor
[backend_test - numpy / tensorflow / pytorch]
*check add / sub / mul / divide work for int / float / Node
* Add test cases for Tensorflow Algebraic operation and fix add, sub name (#292)
[Change name]
*add -> addition
*subtract -> substraction
[Add test case for Tensorflow]
* Specify the datatype to resolve the conflict between different dtype operation
[Test case for pytorch / jax]
* pytorch - [int / int -> int] give different answer for torch when it is dividing two integer
* jax - Different from other backend jax backend return 64bits dtype even operate between 32bits
so put exceptional dtype test case for jax backend
* Add test cases for Tensorflow Algebraic operation and fix add, sub name (#292)
[Change name]
*add -> addition
*subtract -> substraction
[Add test case for Tensorflow]
* Specify the datatype to resolve the conflict between different dtype operation
[Test case for pytorch / jax]
* pytorch - [int / int -> int] give different answer for torch when it is dividing two integer
* jax - Different from other backend jax backend return 64bits dtype even operate between 32bits
so put exceptional dtype test case for jax backend
* Add __add__, __sub__, __mul__, __truediv__ to TestNode Class
Co-authored-by: Chase Roberts <chaseriley@google.com>1 parent a159393 commit 5d6ffc9
10 files changed
Lines changed: 638 additions & 7 deletions
File tree
- tensornetwork
- backends
- numpy
- pytorch
- shell
- tensorflow
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
394 | 420 | | |
395 | 421 | | |
396 | 422 | | |
| |||
404 | 430 | | |
405 | 431 | | |
406 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
407 | 446 | | |
408 | 447 | | |
409 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
374 | 380 | | |
375 | 381 | | |
376 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
377 | 386 | | |
378 | 387 | | |
379 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
324 | 359 | | |
325 | | - | |
326 | 360 | | |
327 | 361 | | |
328 | 362 | | |
329 | 363 | | |
330 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
331 | 382 | | |
332 | | - | |
| 383 | + | |
| 384 | + | |
333 | 385 | | |
334 | 386 | | |
335 | 387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
281 | 290 | | |
282 | 291 | | |
283 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
296 | 325 | | |
297 | | - | |
298 | 326 | | |
299 | 327 | | |
300 | 328 | | |
301 | 329 | | |
302 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
303 | 346 | | |
304 | | - | |
| 347 | + | |
| 348 | + | |
305 | 349 | | |
306 | 350 | | |
307 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
293 | 299 | | |
294 | 300 | | |
295 | 301 | | |
296 | 302 | | |
297 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
298 | 307 | | |
299 | 308 | | |
300 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
188 | 197 | | |
189 | 198 | | |
190 | 199 | | |
| |||
Lines changed: 46 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
250 | 279 | | |
251 | | - | |
252 | 280 | | |
253 | 281 | | |
254 | 282 | | |
255 | 283 | | |
256 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
257 | 300 | | |
258 | | - | |
| 301 | + | |
| 302 | + | |
259 | 303 | | |
260 | 304 | | |
261 | 305 | | |
| |||
0 commit comments